home *** CD-ROM | disk | FTP | other *** search
/ c't freeware shareware 1997 / CT_SW_97.ISO / mac / Software / bild / macos / povmac68.hqx / POV-Ray 3 / Documentation / POVRAY.DOC < prev    next >
Text File  |  1997-02-03  |  844KB  |  21,272 lines

  1.  
  2.                     Persistence of Vision(tm) Ray-Tracer
  3.                                 (POV-Ray(tm))
  4.  
  5.                           User's Documentation 3.0
  6.  
  7.                          Copyright 1997 POV-Team(tm)
  8.  
  9.  
  10. 1                Introduction
  11.    1.1              Notation
  12. 2                Program Description
  13.    2.1              What is Ray-Tracing?
  14.    2.2              What is POV-Ray?
  15.    2.3              Which Version of POV-Ray should you use?
  16.       2.3.1            IBM-PC and Compatibles
  17.          2.3.1.1          MS-DOS
  18.          2.3.1.2          Windows
  19.          2.3.1.3          Linux
  20.       2.3.2            Apple Macintosh
  21.       2.3.3            Commodore Amiga
  22.       2.3.4            SunOS
  23.       2.3.5            Generic Unix
  24.       2.3.6            All Versions
  25.       2.3.7            Compiling POV-Ray
  26.          2.3.7.1          Directory Structure
  27.          2.3.7.2          Configuring POV-Ray Source
  28.          2.3.7.3          Conclusion
  29.    2.4              Where to Find POV-Ray Files
  30.       2.4.1            POV-Ray Forum on CompuServe
  31.       2.4.2            Internet
  32.       2.4.3            PC Graphics Area on America On-Line
  33.       2.4.4            The Graphics Alternative BBS in El Cerrito, CA
  34.       2.4.5            PCGNet
  35.       2.4.6            POV-Ray Related Books and CD-ROMs
  36. 3                Quick Start
  37.    3.1              Installing POV-Ray
  38.    3.2              Basic Usage
  39.       3.2.1            Running Files in Other Directories
  40.       3.2.2            INI Files
  41.       3.2.3            Alternatives to POVRAY.INI
  42.       3.2.4            Batch Files
  43.       3.2.5            Display Types
  44. 4                Beginning Tutorial
  45.    4.1              Our First Image
  46.       4.1.1            Understanding POV-Ray's Coordinate System
  47.       4.1.2            Adding Standard Include Files
  48.       4.1.3            Adding a Camera
  49.       4.1.4            Describing an Object
  50.       4.1.5            Adding Texture to an Object
  51.       4.1.6            Defining a Light Source
  52.    4.2              Using the Camera
  53.       4.2.1            Using Focal Blur
  54.    4.3              Simple Shapes
  55.       4.3.1            Box Object
  56.       4.3.2            Cone Object
  57.       4.3.3            Cylinder Object
  58.       4.3.4            Plane Object
  59.       4.3.5            Standard Include Objects
  60.    4.4              Advanced Shapes
  61.       4.4.1            Bicubic Patch Object
  62.       4.4.2            Blob Object
  63.          4.4.2.1          Component Types and Other New Features
  64.          4.4.2.2          Complex Blob Constructs and Negative Strength
  65.       4.4.3            Height Field Object
  66.       4.4.4            Lathe Object
  67.          4.4.4.1          Understanding The Concept of Splines
  68.       4.4.5            Mesh Object
  69.       4.4.6            Polygon Object
  70.       4.4.7            Prism Object
  71.          4.4.7.1          Teaching An Old Spline New Tricks
  72.          4.4.7.2          Smooth Transitions
  73.          4.4.7.3          Multiple Sub-Shapes
  74.          4.4.7.4          Conic Sweeps And The Tapering Effect
  75.       4.4.8            Superquadric Ellipsoid Object
  76.       4.4.9            Surface of Revolution Object
  77.       4.4.10           Text Object
  78.       4.4.11           Torus Object
  79.    4.5              CSG Objects
  80.       4.5.1            What is CSG?
  81.       4.5.2            CSG Union
  82.       4.5.3            CSG Intersection
  83.       4.5.4            CSG Difference
  84.       4.5.5            CSG Merge
  85.       4.5.6            CSG Pitfalls
  86.          4.5.6.1          Coincidence Surfaces
  87.    4.6              The Light Source
  88.       4.6.1            The Ambient Light Source
  89.       4.6.2            The Pointlight Source
  90.       4.6.3            The Spotlight Source
  91.       4.6.4            The Cylindrical Light Source
  92.       4.6.5            The Area Light Source
  93.       4.6.6            Assigning an Object to a Light Source
  94.       4.6.7            Light Source Specials
  95.          4.6.7.1          Using Shadowless Lights
  96.          4.6.7.2          Using Light Fading
  97.          4.6.7.3          Light Sources and Atmosphere
  98.    4.7              Simple Texture Options
  99.       4.7.1            Surface Finishes
  100.       4.7.2            Adding Bumpiness
  101.       4.7.3            Creating Color Patterns
  102.       4.7.4            Pre-defined Textures
  103.    4.8              Advanced Texture Options
  104.       4.8.1            Pigment and Normal Patterns
  105.       4.8.2            Pigments
  106.          4.8.2.1          Using Color List Pigments
  107.          4.8.2.2          Using Pigment and Patterns
  108.          4.8.2.3          Using Pattern Modifiers
  109.          4.8.2.4          Using Transparent Pigments and Layered Textures
  110.          4.8.2.5          Using Pigment Maps
  111.       4.8.3            Normals
  112.          4.8.3.1          Using Basic Normal Modifiers
  113.          4.8.3.2          Blending Normals
  114.       4.8.4            Finishes
  115.          4.8.4.1          Using Ambient
  116.          4.8.4.2          Using Surface Highlights
  117.          4.8.4.3          Using Reflection and Metallic
  118.          4.8.4.4          Using Refraction
  119.          4.8.4.5          Adding Light Attenuation
  120.          4.8.4.6          Using Faked Caustics
  121.             4.8.4.6.1        What are Caustics?
  122.             4.8.4.6.2        Applying Caustics to a Scene
  123.             4.8.4.6.3        Caustics And Normals
  124.          4.8.4.7          Using Iridescence
  125.       4.8.5            Halos
  126.          4.8.5.1          What are Halos?
  127.          4.8.5.2          The Emitting Halo
  128.  
  129.             4.8.5.2.1        Starting with a Basic Halo
  130.             4.8.5.2.2        Increasing the Brightness
  131.             4.8.5.2.3        Adding Some Turbulence
  132.             4.8.5.2.4        Resizing the Halo
  133.             4.8.5.2.5        Using Frequency to Improve Realism
  134.             4.8.5.2.6        Changing the Halo Color
  135.          4.8.5.3          The Glowing Halo
  136.          4.8.5.4          The Attenuating Halo
  137.             4.8.5.4.1        Making a Cloud
  138.             4.8.5.4.2        Scaling the Halo Container
  139.             4.8.5.4.3        Adding Additional Halos
  140.          4.8.5.5          The Dust Halo
  141.             4.8.5.5.1        Starting With an Object Lit by a Spotlight
  142.             4.8.5.5.2        Adding Some Dust
  143.             4.8.5.5.3        Decreasing the Dust Density
  144.             4.8.5.5.4        Making the Shadows Look Good
  145.             4.8.5.5.5        Adding Turbulence
  146.             4.8.5.5.6        Using a Coloured Dust
  147.          4.8.5.6          Halo Pitfalls
  148.             4.8.5.6.1        Where Halos are Allowed
  149.             4.8.5.6.2        Overlapping Container Objects
  150.             4.8.5.6.3        Multiple Attenuating Halos
  151.             4.8.5.6.4        Halos and Hollow Objects
  152.             4.8.5.6.5        Scaling a Halo Container
  153.             4.8.5.6.6        Choosing a Sampling Rate
  154.             4.8.5.6.7        Using Turbulence
  155.    4.9              Working With Special Textures
  156.       4.9.1            Working With Pigment Maps
  157.       4.9.2            Working With Normal Maps
  158.       4.9.3            Working With Texture Maps
  159.       4.9.4            Working With List Textures
  160.       4.9.5            What About Tiles?
  161.       4.9.6            Average Function
  162.       4.9.7            Working With Layered Textures
  163.          4.9.7.1          Declaring Layered Textures
  164.          4.9.7.2          Another Layered Textures Example
  165.       4.9.8            When All Else Fails: Material Maps
  166.       4.9.9            Limitations Of Special Textures
  167.    4.10             Using Atmospheric Effects
  168.       4.10.1           The Background
  169.       4.10.2           The Sky Sphere
  170.          4.10.2.1         Creating a Sky with a Color Gradient
  171.          4.10.2.2         Adding the Sun
  172.          4.10.2.3         Adding Some Clouds
  173.       4.10.3           The Fog
  174.          4.10.3.1         A Constant Fog
  175.          4.10.3.2         Setting a Minimum Translucency
  176.          4.10.3.3         Creating a Filtering Fog
  177.          4.10.3.4         Adding Some Turbulence to the Fog
  178.          4.10.3.5         Using Ground Fog
  179.          4.10.3.6         Using Multiple Layers of Fog
  180.          4.10.3.7         Fog and Hollow Objects
  181.       4.10.4           The Atmosphere
  182.          4.10.4.1         Starting With an Empty Room
  183.          4.10.4.2         Adding Dust to the Room
  184.          4.10.4.3         Choosing a Good Sampling Rate
  185.          4.10.4.4         Using a Coloured Atmosphere
  186.          4.10.4.5         Atmosphere Tips
  187.             4.10.4.5.1       Choosing the Distance and Scattering Parameters
  188.             4.10.4.5.2       Atmosphere and Light Sources
  189.             4.10.4.5.3       Atmosphere Scattering Types
  190.             4.10.4.5.4       Increasing the Image Resolution
  191.             4.10.4.5.5       Using Hollow Objects and Atmosphere
  192.       4.10.5           The Rainbow
  193.          4.10.5.1         Starting With a Simple Rainbow
  194.          4.10.5.2         Increasing the Rainbow's Translucency
  195.          4.10.5.3         Using a Rainbow Arc
  196.       4.10.6           Animation
  197.          4.10.6.1         The Clock Variable: Key To It All
  198.          4.10.6.2         Clock Dependant Variables And Multi-Stage Animation
  199.          4.10.6.3         The Phase Keyword
  200.          4.10.6.4         Do Not Use Jitter Or Crand
  201.          4.10.6.5         INI File Settings
  202. 5                POV-Ray Reference
  203. 6                POV-Ray Options
  204.    6.1              Setting POV-Ray Options
  205.       6.1.1            Command Line Switches
  206.       6.1.2            Using INI Files
  207.       6.1.3            Using the POVINI Environment Variable
  208.    6.2              Options Reference
  209.       6.2.1            Animation Options
  210.          6.2.1.1          External Animation Loop
  211.          6.2.1.2          Internal Animation Loop
  212.          6.2.1.3          Subsets of Animation Frames
  213.          6.2.1.4          Cyclic Animation
  214.          6.2.1.5          Field Rendering
  215.       6.2.2            Output Options
  216.          6.2.2.1          General Output Options
  217.             6.2.2.1.1        Height and Width of Output
  218.             6.2.2.1.2        Partial Output Options
  219.             6.2.2.1.3        Interrupting Options
  220.             6.2.2.1.4        Resuming Options
  221.          6.2.2.2          Display Output Options
  222.             6.2.2.2.1        Display Hardware Settings
  223.             6.2.2.2.2        Display Related Settings
  224.             6.2.2.2.3        Mosaic Preview
  225.          6.2.2.3          File Output Options
  226.             6.2.2.3.1        Output File Type
  227.             6.2.2.3.2        Output File Name
  228.             6.2.2.3.3        Output File Buffer
  229.          6.2.2.4          CPU Utilization Histogram
  230.             6.2.2.4.1        File Type
  231.             6.2.2.4.2        File Name
  232.             6.2.2.4.3        Grid Size
  233.       6.2.3            Scene Parsing Options
  234.          6.2.3.1          Input File Name
  235.          6.2.3.2          Library Paths
  236.          6.2.3.3          Language Version
  237.          6.2.3.4          Removing User Bounding
  238.       6.2.4            Shell-out to Operating System
  239.          6.2.4.1          String Substitution in Shell Commands
  240.          6.2.4.2          Shell Command Sequencing
  241.          6.2.4.3          Shell Command Return Actions
  242.       6.2.5            Text Output
  243.          6.2.5.1          Text Streams
  244.          6.2.5.2          Console Text Output
  245.          6.2.5.3          Directing Text Streams to Files
  246.          6.2.5.4          Help Screen Switches
  247.       6.2.6            Tracing Options
  248.          6.2.6.1          Quality Settings
  249.          6.2.6.2          Radiosity Setting
  250.          6.2.6.3          Automatic Bounding Control
  251.          6.2.6.4          Anti-Aliasing Options
  252. 7                Scene Description Language
  253.    7.1              Language Basics
  254.       7.1.1            Identifiers and Keywords
  255.       7.1.2            Comments
  256.  
  257.       7.1.3            Float Expressions
  258.          7.1.3.1          Float Literals
  259.          7.1.3.2          Float Identifiers
  260.          7.1.3.3          Float Operators
  261.       7.1.4            Vector Expressions
  262.          7.1.4.1          Vector Literals
  263.          7.1.4.2          Vector Identifiers
  264.          7.1.4.3          Vector Operators
  265.          7.1.4.4          Operator Promotion
  266.       7.1.5            Specifying Colors
  267.          7.1.5.1          Color Vectors
  268.          7.1.5.2          Color Keywords
  269.          7.1.5.3          Color Identifiers
  270.          7.1.5.4          Color Operators
  271.          7.1.5.5          Common Color Pitfalls
  272.       7.1.6            Strings
  273.          7.1.6.1          String Literals
  274.          7.1.6.2          String Identifiers
  275.       7.1.7            Built-in Identifiers
  276.          7.1.7.1          Constant Built-in Identifiers
  277.          7.1.7.2          Built-in Identifier 'clock'
  278.          7.1.7.3          Built-in Identifier 'version'
  279.       7.1.8            Functions
  280.          7.1.8.1          Float Functions
  281.          7.1.8.2          Vector Functions
  282.          7.1.8.3          String Functions
  283.    7.2              Language Directives
  284.       7.2.1            Include Files
  285.       7.2.2            Declare
  286.          7.2.2.1          Declaring identifiers
  287.       7.2.3            Default Directive
  288.       7.2.4            Version Directive
  289.       7.2.5            Conditional Directives
  290.          7.2.5.1          IF ELSE Directives
  291.          7.2.5.2          IFDEF Directives
  292.          7.2.5.3          IFNDEF Directives
  293.          7.2.5.4          SWITCH CASE and RANGE Directives
  294.          7.2.5.5          WHILE Directive
  295.       7.2.6            User Message Directives
  296.          7.2.6.1          Text Message Streams
  297.          7.2.6.2          Text Formatting
  298.    7.3              POV-Ray Coordinate System
  299.       7.3.1            Transformations
  300.          7.3.1.1          Translate
  301.          7.3.1.2          Scale
  302.          7.3.1.3          Rotate
  303.          7.3.1.4          Matrix Keyword
  304.       7.3.2            Transformation Order
  305.       7.3.3            Transform Identifiers
  306.       7.3.4            Transforming Textures and Objects
  307.    7.4              Camera
  308.       7.4.1            Type of Projection
  309.       7.4.2            Focal Blur
  310.       7.4.3            Camera Ray Perturbation
  311.       7.4.4            Placing the Camera
  312.          7.4.4.1          Location and Look_At
  313.          7.4.4.2          The Sky Vector
  314.          7.4.4.3          The Direction Vector
  315.          7.4.4.4          Angle
  316.          7.4.4.5          Up and Right Vectors
  317.             7.4.4.5.1        Aspect Ratio
  318.             7.4.4.5.2        Handedness
  319.          7.4.4.6          Transforming the Camera
  320.       7.4.5            Camera Identifiers
  321.    7.5              Objects
  322.       7.5.1            Empty and Solid Objects
  323.          7.5.1.1          Halo Pitfall
  324.          7.5.1.2          Refraction Pitfall
  325.       7.5.2            Finite Solid Primitives
  326.          7.5.2.1          Blob
  327.          7.5.2.2          Box
  328.          7.5.2.3          Cone
  329.          7.5.2.4          Cylinder
  330.          7.5.2.5          Height Field
  331.          7.5.2.6          Julia Fractal
  332.          7.5.2.7          Lathe
  333.          7.5.2.8          Prism
  334.          7.5.2.9          Sphere
  335.          7.5.2.10         Superquadric Ellipsoid
  336.          7.5.2.11         Surface of Revolution
  337.          7.5.2.12         Text
  338.          7.5.2.13         Torus
  339.       7.5.3            Finite Patch Primitives
  340.          7.5.3.1          Bicubic Patch
  341.          7.5.3.2          Disc
  342.          7.5.3.3          Mesh
  343.          7.5.3.4          Polygon
  344.          7.5.3.5          Triangle and Smooth Triangle
  345.       7.5.4            Infinite Solid Primitives
  346.          7.5.4.1          Plane
  347.          7.5.4.2          Poly, Cubic and Quartic
  348.          7.5.4.3          Quadric
  349.       7.5.5            Constructive Solid Geometry
  350.          7.5.5.1          About CSG
  351.          7.5.5.2          Inside and Outside
  352.          7.5.5.3          Inverse
  353.          7.5.5.4          Union
  354.          7.5.5.5          Intersection
  355.          7.5.5.6          Difference
  356.          7.5.5.7          Merge
  357.       7.5.6            Light Sources
  358.          7.5.6.1          Point Lights
  359.          7.5.6.2          Spotlights
  360.          7.5.6.3          Cylindrical Lights
  361.          7.5.6.4          Area Lights
  362.          7.5.6.5          Shadowless Lights
  363.          7.5.6.6          Looks_like
  364.          7.5.6.7          Light Fading
  365.          7.5.6.8          Atmosphere Interaction
  366.          7.5.6.9          Atmospheric Attenuation
  367.       7.5.7            Object Modifiers
  368.          7.5.7.1          Clipped_By
  369.          7.5.7.2          Bounded_By
  370.          7.5.7.3          Hollow
  371.          7.5.7.4          No_Shadow
  372.          7.5.7.5          Sturm
  373.    7.6              Textures
  374.       7.6.1            Pigment
  375.          7.6.1.1          Solid Color Pigments
  376.          7.6.1.2          Color List Pigments
  377.          7.6.1.3          Color Maps
  378.          7.6.1.4          Pigment Maps
  379.          7.6.1.5          Image Maps
  380.             7.6.1.5.1        Specifying an Image Map
  381.             7.6.1.5.2        The map_type Option
  382.             7.6.1.5.3        The Filter and Transmit Bitmap Modifiers
  383.             7.6.1.5.4        Using the Alpha Channel
  384.  
  385.          7.6.1.6          Quick Color
  386.       7.6.2            Normal
  387.          7.6.2.1          Slope Maps
  388.          7.6.2.2          Normal Maps
  389.          7.6.2.3          Bump Maps
  390.             7.6.2.3.1        Specifying a Bump Map
  391.             7.6.2.3.2        Bump_Size
  392.             7.6.2.3.3        Use_Index and Use_Color
  393.       7.6.3            Finish
  394.          7.6.3.1          Ambient
  395.          7.6.3.2          Diffuse Reflection Items
  396.             7.6.3.2.1        Diffuse
  397.             7.6.3.2.2        Brilliance
  398.             7.6.3.2.3        Crand Graininess
  399.          7.6.3.3          Highlights
  400.             7.6.3.3.1        Phong Highlights
  401.             7.6.3.3.2        Specular Highlight
  402.             7.6.3.3.3        Metallic Highlight Modifier
  403.          7.6.3.4          Specular Reflection
  404.          7.6.3.5          Refraction
  405.             7.6.3.5.1        Light Attenuation
  406.             7.6.3.5.2        Faked Caustics
  407.          7.6.3.6          Iridescence
  408.       7.6.4            Halo
  409.          7.6.4.1          Halo Mapping
  410.          7.6.4.2          Multiple Halos
  411.          7.6.4.3          Halo Type
  412.             7.6.4.3.1        Attenuating
  413.             7.6.4.3.2        Dust
  414.             7.6.4.3.3        Emitting
  415.             7.6.4.3.4        Glowing
  416.          7.6.4.4          Density Mapping
  417.             7.6.4.4.1        Box Mapping
  418.             7.6.4.4.2        Cylindrical Mapping
  419.             7.6.4.4.3        Planar Mapping
  420.             7.6.4.4.4        Spherical Mapping
  421.          7.6.4.5          Density Function
  422.             7.6.4.5.1        Constant
  423.             7.6.4.5.2        Linear
  424.             7.6.4.5.3        Cubic
  425.             7.6.4.5.4        Poly
  426.          7.6.4.6          Halo Color Map
  427.          7.6.4.7          Halo Sampling
  428.             7.6.4.7.1        Number of Samples
  429.             7.6.4.7.2        Super-Sampling
  430.             7.6.4.7.3        Jitter
  431.          7.6.4.8          Halo Modifiers
  432.             7.6.4.8.1        Frequency Modifier
  433.             7.6.4.8.2        Phase Modifier
  434.             7.6.4.8.3        Transformation Modifiers
  435.       7.6.5            Special Textures
  436.          7.6.5.1          Texture Maps
  437.          7.6.5.2          Tiles
  438.          7.6.5.3          Material Maps
  439.             7.6.5.3.1        Specifying a Material Map
  440.       7.6.6            Layered Textures
  441.       7.6.7            Patterns
  442.          7.6.7.1          Agate
  443.          7.6.7.2          Average
  444.          7.6.7.3          Bozo
  445.          7.6.7.4          Brick
  446.          7.6.7.5          Bumps
  447.          7.6.7.6          Checker
  448.          7.6.7.7          Crackle
  449.          7.6.7.8          Dents
  450.          7.6.7.9          Gradient
  451.          7.6.7.10         Granite
  452.          7.6.7.11         Hexagon
  453.          7.6.7.12         Leopard
  454.          7.6.7.13         Mandel
  455.          7.6.7.14         Marble
  456.          7.6.7.15         Onion
  457.          7.6.7.16         Quilted
  458.          7.6.7.17         Radial
  459.          7.6.7.18         Ripples
  460.          7.6.7.19         Spiral1
  461.          7.6.7.20         Spiral2
  462.          7.6.7.21         Spotted
  463.          7.6.7.22         Waves
  464.          7.6.7.23         Wood
  465.          7.6.7.24         Wrinkles
  466.       7.6.8            Pattern Modifiers
  467.          7.6.8.1          Transforming Patterns
  468.          7.6.8.2          Frequency and Phase
  469.          7.6.8.3          Waveform
  470.          7.6.8.4          Turbulence
  471.          7.6.8.5          Octaves
  472.          7.6.8.6          Lambda
  473.          7.6.8.7          Omega
  474.          7.6.8.8          Warps
  475.             7.6.8.8.1        Black Hole Warp
  476.             7.6.8.8.2        Repeat Warp
  477.             7.6.8.8.3        Turbulence Warp
  478.          7.6.8.9          Bitmap Modifiers
  479.             7.6.8.9.1        The once Option
  480.             7.6.8.9.2        The "map_type" Option
  481.             7.6.8.9.3        The interpolate Option
  482.    7.7              Atmospheric Effects
  483.       7.7.1            Atmosphere
  484.       7.7.2            Background
  485.       7.7.3            Fog
  486.       7.7.4            Sky Sphere
  487.       7.7.5            Rainbow
  488.    7.8              Global Settings
  489.       7.8.1            ADC_Bailout
  490.       7.8.2            Ambient Light
  491.       7.8.3            Assumed_Gamma
  492.          7.8.3.1          Monitor Gamma
  493.          7.8.3.2          Image File Gamma
  494.          7.8.3.3          Scene File Gamma
  495.       7.8.4            HF_Gray_16
  496.       7.8.5            Irid_Wavelength
  497.       7.8.6            Max_Trace_Level
  498.       7.8.7            Max_Intersections
  499.       7.8.8            Number_Of_Waves
  500.       7.8.9            Radiosity
  501.          7.8.9.1          How Radiosity Works
  502.          7.8.9.2          Adjusting Radiosity
  503.             7.8.9.2.1        brightness
  504.             7.8.9.2.2        count
  505.             7.8.9.2.3        distance_maximum
  506.             7.8.9.2.4        error_bound
  507.             7.8.9.2.5        gray_threshold
  508.             7.8.9.2.6        low_error_factor
  509.             7.8.9.2.7        minimum_reuse
  510.             7.8.9.2.8        nearest_count
  511.             7.8.9.2.9        radiosity_quality
  512.  
  513.             7.8.9.2.10       recursion_limit
  514.          7.8.9.3          Tips on Radiosity
  515.  
  516.                              *** APPENDICES ***
  517.  
  518. A                Copyright
  519.    A.1              General License Agreement
  520.    A.2              Usage Provisions
  521.    A.3              General Rules for All Distributions
  522.    A.4              Definition of "Full Package"
  523.    A.5              Conditions for On-Line Services and BBS's Including Inter
  524.    A.6              Online or Remote Execution of POV-Ray
  525.    A.7              Conditions for Distribution of Custom Versions
  526.    A.8              Conditions for Commercial Bundling
  527.    A.9              Retail Value of this Software
  528.    A.10             Other Provisions
  529.    A.11             Revocation of License
  530.    A.12             Disclaimer
  531.    A.13             Technical Support
  532. B                Authors
  533. C                Contacting the Authors
  534. D                Postcards for POV-Ray Team Members
  535. E                Credits
  536. F                Tips and Hints
  537.    F.1              Scene Design Tips
  538.    F.2              Scene Debugging Tips
  539.    F.3              Animation Tips
  540.    F.4              Texture Tips
  541.    F.5              Height Field Tips
  542.    F.6              Converting "Handedness"
  543. G                Frequently Asked Questions
  544.    G.1              General Questions
  545.    G.2              POV-Ray Options Questions
  546.    G.3              Include File Questions
  547.    G.4              Object Questions
  548.       G.4.1            Height Field Questions
  549.       G.4.2            Text Questions
  550.    G.5              Atmospheric Questions
  551.       G.5.1            Atmosphere Questions
  552.       G.5.2            Fog Questions
  553. H                Suggested Reading
  554. I                Help on Help
  555.  
  556.  
  557. 1                Introduction
  558.  
  559. This document details the use of the Persistence of Vision(tm) Ray-Tracer
  560. (POV-Ray(tm)). It is broken down into four parts: the installation guide, the
  561. tutorial guide, the reference guide and the appendix. The first part (see
  562. chapter "Program Description" and chapter "Quick Start") tells you where to
  563. get and how to install POV-Ray. It also gives a short introduction to
  564. ray-tracing. The tutorial explains step by step how to use the different
  565. features of POV-Ray (see chapter "Beginning Tutorial"). The reference gives a
  566. complete description of all features available in POV-Ray by explaining all
  567. available options (set either by command line switches or by INI file
  568. keywords) and the scene description language (see chapter "POV-Ray Reference"
  569. , chapter "POV-Ray Options" and chapter "Scene Description Language"). The
  570. appendix includes some tips and hints, suggested reading, contact addresses
  571. and legal information.
  572.  
  573.  
  574. 1.1              Notation
  575.  
  576. Throughout this document the following notation is used to mark keywords of
  577. the scene description language, command line switches, INI file keywords and
  578. file names.
  579.  
  580.   name  scene description keyword
  581.   name  command line option
  582.   name  INI file keyword
  583.   name  file name
  584.   name  Internet address, Usenet group
  585.  
  586.  
  587. In the plain ASCII version of the document there is no difference between the
  588. different notations.
  589.  
  590. 2                Program Description
  591.  
  592. The Persistence of Vision(tm) Ray-Tracer creates three-dimensional,
  593. photo-realistic images using a rendering technique called ray-tracing. It
  594. reads in a text file containing information describing the objects and
  595. lighting in a scene and generates an image of that scene from the view point
  596. of a camera also described in the text file. Ray-tracing is not a fast
  597. process by any means, but it produces very high quality images with realistic
  598. reflections, shading, perspective and other effects.
  599.  
  600. 2.1              What is Ray-Tracing?
  601.  
  602. Ray-tracing is a rendering technique that calculates an image of a scene by
  603. shooting rays into the scene. The scene is built from shapes, light sources,
  604. a camera, materials, special features, etc.
  605.  
  606. For every pixel in the final image one or more viewing rays are shot into the
  607. scene and tested for intersection with any of the objects in the scene.
  608. Viewing rays originate from the viewer, represented by the camera, and pass
  609. through the viewing window (representing the final image).
  610.  
  611. Every time an object is hit, the color of the surface at that point is
  612. calculated. For this purpose the amount of light coming from any light source
  613. in the scene is determined to tell whether the surface point lies in shadow
  614. or not. If the surface is reflective or translucent new rays are set up and
  615. traced in order to determine the contribution of the reflected and refracted
  616. light to the final surface color.
  617.  
  618. Special features like inter-diffuse reflection (radiosity), atmospheric
  619. effects and area lights make it necessary to shoot a lot of additional rays
  620. into the scene for every pixel.
  621.  
  622. 2.2              What is POV-Ray?
  623.  
  624. The Persistence of Vision(tm) Ray-Tracer was developed from DKBTrace 2.12
  625. (written by David K. Buck and Aaron A. Collins) by a bunch of people, called
  626. the POV-Team(tm), in their spare time. The headquarters of the POV-Team is in
  627. the POVRAY forum on CompuServe (see "POV-Ray Forum on CompuServe" for more
  628. details).
  629.  
  630. The POV-Ray(tm) package includes detailed instructions on using the
  631. ray-tracer and creating scenes. Many stunning scenes are included with
  632. POV-Ray so you can start creating images immediately when you get the
  633. package. These scenes can be modified so you don't have to start from
  634. scratch.
  635.  
  636. In addition to the pre-defined scenes, a large library of pre-defined shapes
  637. and materials is provided. You can include these shapes and materials in your
  638. own scenes by just including the name of the shape or material and their name
  639. of their appropriate source file.
  640.  
  641. Here are some highlights of POV-Ray's features:
  642.  
  643.   * Spotlights, cylindrical lights and area lights for sophisticatedre.ures.
  644.   * Basic shape primitives such as ... spheres, boxes, quadrics, cylinders,
  645.   * Advanced shape primitives such as ... torii (donuts), bezier patches,
  646.     height fields (mountains), blobs, quartics, smooth triangles, text,
  647.     fractals, superquadrics, surfaces of revolution, prisms, polygons, lathes
  648.   * Shapes can easily be combined to create new complex shapes using
  649.     Constructive Solid Geometry (CSG). POV-Ray supports unions, merges,
  650.   * Objects are assigned materials called textures (a texture describes the
  651.   * Built-in color and normal patterns: Agate, Bozo, Bumps, Checker, Crackle,
  652.     Dents, Granite, Gradient, Hexagon, Leopard, Mandel, Marble, Onion,
  653.     Quilted, Ripples, Spotted, Sprial, Radial, Waves, Wood, Wrinkles and
  654.   * Users can create their own textures or use pre-defined textures such as
  655.   * Combine textures using layering of semi-transparent textures or tiles of
  656.   * Display preview of image while computing (not available on all
  657.   * Continue rendering a halted partial scene later.
  658.  
  659. 2.3              Which Version of POV-Ray should you use?
  660.  
  661. POV-Ray can be used under MS-DOS, Windows 3.x, Windows for Workgroups 3.11,
  662. Windows 95, Windows NT, Apple Macintosh 68k, Power PC, Commodore Amiga,
  663. Linux, UNIX and other platforms.
  664.  
  665. The latest versions of the necessary files are available over CompuServe,
  666. Internet, America Online and several BBS's. See section "Where to Find
  667. POV-Ray Files" for more info.
  668.  
  669. 2.3.1            IBM-PC and Compatibles
  670.  
  671. Currently there are three different versions for the IBM-PC running under
  672. different operating systems (MS-DOS, Windows and Linux) as described below.
  673.  
  674. 2.3.1.1          MS-DOS
  675.  
  676. The MS-DOS version runs under MS-DOS or as a DOS application under Windows
  677. 95, Windows NT, Windows 3.1 or Windows for Workgroups 3.11. It also runs
  678. under OS/2 and Warp.
  679.  
  680. Required hardware and software:
  681.  
  682.   - About 6 meg disk space to install and 2-10 meg or more beyond that for
  683.   - A text editor capable of editing plain ASCII text files. The EDIT program
  684.   - Graphic file viewer capable of viewing GIF and perhaps TGA and PNG
  685. formats.
  686.  
  687.  
  688. Required POV-Ray files:
  689.  
  690.   - POVMSDOS.EXE - a self-extracting archive containing the program, sample
  691.     scenes, standard include files and documentation in a hypertext help
  692.     format with help viewer. This file may be split into smaller files for
  693.     easier downloading. Check the directory of your download or ftp site to
  694.     see if other files are needed.
  695.  
  696.  
  697. Recommended:
  698.  
  699.   - SVGA display preferably with VESA interface and high color or true color
  700. ability.
  701.  
  702.  
  703. Optional: The source code is not needed to use POV-Ray. It is provided for
  704. the curious and adventurous.
  705.  
  706.   - POVMSD_S.ZIP - The C source code for POV-Ray for MS-DOS Contains generic
  707.     parts and MS-DOS specific parts. It does not include sample scenes,
  708.     standard include files and documentation so you should also get the
  709.   - A C compiler that can create 32-bit protected mode applications. We
  710.     support Watcom 10.5a, Borland 4.52 with DOS Power Pack and limited
  711.     graphics under DJGPP 1.12maint4. DJGPP 2.0 not supported.
  712.  
  713. 2.3.1.2          Windows
  714.  
  715. The Windows version runs under Windows'95, Windows NT and under Windows 3.1
  716. or 3.11 if Win32s extensions are added. Also runs under OS/2 Warp.
  717.  
  718. Required hardware and software:
  719.  
  720.   - About 12 meg disk space to install and 2-10 meg or more beyond that for
  721.     working space.
  722.  
  723.  
  724. Required POV-Ray files:
  725.  
  726.   - User archive POVWIN3.EXE - a self-extracting archive containing the
  727.     program, sample scenes, standard include files and documentation. This
  728.     file may be split into smaller files for easier downloading. Check the
  729.     directory of your download or ftp site to see if other files are needed.
  730.  
  731.  
  732. Recommended:
  733.  
  734.   - SVGA display preferably with high color or true color ability and drivers
  735. installed.
  736.  
  737.  
  738. Optional: The source code is not needed to use POV-Ray. It is provided for
  739. the curious and adventurous.
  740.  
  741.   - POVWIN_S.ZIP --- The C source code for POV-Ray for Windows. Contains
  742.     generic parts and Windows specific parts. It does not include sample
  743.     scenes, standard include files and documentation so you should also get
  744.   - POV-Ray can only be compiled using C compilers that create 32-bit Windows
  745.     applications. We support Watcom 10.5a, Borland 4.52/5.0 compilers. The
  746.     source code is not needed to use POV-Ray. It is provided for the curious
  747.     and adventurous.
  748.  
  749. 2.3.1.3          Linux
  750.  
  751. Required hardware and software:
  752.  
  753.   - About 6 meg disk space to install and 2-10 meg or more beyond that for
  754.   - Any recent (1994 onwards) Linux kernel and support for ELF format
  755.   - ELF libraries libc.so.5, libm.so.5 and one or both of libX11.so.6 or
  756. libvga.so.1.
  757.  
  758.  
  759. Required POV-Ray files:
  760.  
  761.   - POVLINUX.TGZ or POVLINUX.TAR.GZ - archive containing an official binary
  762.     for each SVGALib and X-Windows modes. Also contains sample scenes,
  763.     standard include files and documentation.
  764.  
  765.  
  766. Recommended:
  767.  
  768.   - Graphic file viewer capable of viewing PPM, TGA or PNG formats.
  769.  
  770.  
  771. Optional: The source code is not needed to use POV-Ray. It is provided for
  772. the curious and adventurous.
  773.  
  774.   - POVUNI_S.TAR.GZ or POVUNI_S.TGZ - The C source code for POV-Ray for
  775.     Linux. Contains generic parts and Linux specific parts. It does not
  776.     include sample scenes, standard include files and documentation so you
  777.   - The GNU C compiler and (optionally) the X include files and libraries and
  778.     KNOWLEDGE OF HOW TO USE IT. Although we provide source code for generic
  779.     Unix systems, we do not provide technical support on how to compile the
  780. program.
  781.  
  782. 2.3.2            Apple Macintosh
  783.  
  784. The Macintosh versions run under Apple's MacOS operating system version 7.0
  785. or better, on any 68020/030/040-based Macintosh (with or without a floating
  786. point coprocessor) or any of the Power Macintosh computers.
  787.  
  788. Required hardware and software:
  789.  
  790.   - A 68020 or better CPU without a floating point unit (LC or Performa or
  791.   - A 68020 or better CPU *with* a floating point unit (Mac II or Quadra
  792.   - About 6 meg free disk space to install and an additional 2-10 meg free).
  793.   - Graphic file viewer utility capable of viewing Mac PICT, GIF and perhaps
  794.     TGA and PNG formats (the shareware GIFConverter or GraphicConverter
  795.     applications are good.)
  796.  
  797.  
  798. Required POV-Ray files:
  799.  
  800.   - POVMACNF.SIT or POVMACNF.SIT.HQX - a Stuffit archive containing the
  801.     non-FPU 68K Macintosh application, sample scenes, standard include files
  802.   - POVMAC68.SIT or POVMAC68.SIT.HQX - a Stuffit archive containing the FPU
  803.     68K Macintosh application, sample scenes, standard include files and
  804.   - POVPMAC.SIT or POVPMAC.SIT.HQX - a Stuffit archive containing the native
  805.     Power Macintosh application, sample scenes, standard include files and
  806. documentation.
  807.  
  808.  
  809. Recommended:
  810.  
  811.   - 8 meg or more RAM for 68K Macintosh; 16 meg or more for Power Macintosh
  812.   - Color monitor preferred, 256 colors OK, but thousands or millions of
  813.     colors is even better.
  814.  
  815.  
  816. Optional: The source code is not needed to use POV-Ray. It is provided for
  817. the curious and adventurous. POV-Ray can be compiled using Apple's MPW 3.3,
  818. Metrowerks CodeWarrior 8 or Symantec 8.
  819.  
  820.   - POVMACS.SIT or POVMACS.SIT.HQX - The full C source code for POV-Ray for
  821.     Macintosh. Contains generic parts and Macintosh specific parts. It does
  822.     not include sample scenes, standard include files and documentation so
  823.     you should also get the executable archive as well.
  824.  
  825. 2.3.3            Commodore Amiga
  826.  
  827. The Amiga version comes in several flavors: 68000/68020 without FPU (not
  828. recommended, very slow), 68020/68881(68882), 68030/68882 and 68040. There are
  829. also two sub-versions, one with a CLI-only interface, and one with a GUI
  830. (requires MUI 3.1). All versions run under OS2.1 and up. Support exists for
  831. pensharing and window display under OS3.x with 256 color palettes and CybeGFX
  832. display library support.
  833.  
  834. Required:
  835.  
  836.   - at least 2 meg of hard disk space for the necessities, 5-20 more
  837.   - an ASCII text editor, GUI configurable to launch the editor of your
  838.   - Graphic file viewer - POV-Ray outputs to PNG, Targa (TGA) and PPM
  839.     formats, converters from the PPMBIN distribution are included to convert
  840.     these to IFF ILBM files.
  841.  
  842.  
  843. Required POV-Ray files:
  844.  
  845.   - POVAMI.LHA - a LHA archive containing executable, sample scenes, standard
  846.     include files and documentation.
  847.  
  848.  
  849. Recommended:
  850.  
  851.   - 24-bit display card (CyberGFX library supported)
  852.  
  853.  
  854. As soon as a stable compiler is released for Amiga PowerPC systems, plans are
  855. to add this to the flavor list.
  856.  
  857. Optional: The source code is not needed to use POV-Ray. It is provided for
  858. the curious and adventurous.
  859.  
  860.   - POVLHA_S.ZIP - The C source code for POV-Ray for Amiga. Contains generic
  861.     parts and Amiga specific parts. It does not include sample scenes,
  862.     standard include files and documentation so you should also get the
  863.     executable archive as well.
  864.  
  865. 2.3.4            SunOS
  866.  
  867. Required hardware and software:
  868.  
  869.   - About 6 meg disk space to install and 2-10 meg or more beyond that for
  870.   - SunOS 4.1.3 or other operating system capable of running such a binary
  871.     (Solaris or possibly Linux for Sparc).
  872.  
  873.  
  874. Required POV-Ray files:
  875.  
  876.   - POVSUNOS.TGZ or POVSUNOS.TAR.GZ - archive containing an official binary
  877.     for each text-only and X-Windows modes. Also contains sample scenes,
  878.     standard include files and documentation.
  879.  
  880.  
  881. Recommended:
  882.  
  883.   - preferably 24-bit TrueColor display ability, although the X display code
  884.   - Graphic file viewer capable of viewing PPM, TGA or PNG formats..
  885.  
  886.  
  887. Optional: The source code is not needed to use POV-Ray. It is provided for
  888. the curious and adventurous.
  889.  
  890.   - POVUNI_S.TGZ or POVUNI_S.TAR.GZ - The C source code for POV-Ray for UNIX.
  891.     Contains generic UNIX parts and Linux specific parts. It does not include
  892.     sample scenes, standard include files and documentation so you should
  893.   - A C compiler and (optionally) the X include files and libraries and
  894.     knowledge of how to use it.
  895.  
  896.  
  897. Although we provide source code for generic Unix systems, we do not provide
  898. technical support on how to compile the program.
  899.  
  900. 2.3.5            Generic Unix
  901.  
  902. Required:
  903.  
  904.   - POVUNI_S.TGZ or POVUNI_S.TAR.GZ - The C source code for POV-Ray for Unix.
  905.     Either archive contains full generic source, Unix and X-Windows specific
  906.   - POVUNI_D.TGZ or POVUNI_D.TAR.GZ or any archive containing the sample
  907.     scenes, standard include files and documentation. This could be the Linux
  908.   - A C compiler for your computer and KNOWLEDGE OF HOW TO USE IT. Although
  909.     we provide source code for generic Unix systems, we do not provide
  910.   - A text editor capable of editing plain ASCII text files.
  911.  
  912.  
  913. Recommended:
  914.  
  915.   - Graphic file viewer capable of viewing PPM, TGA or PNG formats.
  916.  
  917.  
  918. Optional:
  919.  
  920.   - You will need the X-Windows include files as well. If you're not familiar
  921.     with compiling programs for X-Windows you may need some help from someone
  922.     who is knowledgeable at your installation because the X include files and
  923.     libraries are not always in a standard place.
  924.  
  925. 2.3.6            All Versions
  926.  
  927. Each executable archive includes full documentation for POV-Ray itself as
  928. well as specific instructions for using POV-Ray with your type of platform.
  929.  
  930. All versions of the program share the same ray-tracing features like shapes,
  931. lighting and textures. In other words, an IBM-PC can create the same pictures
  932. as a Cray supercomputer as long as it has enough memory.
  933.  
  934. The user will want to get the executable that best matches their computer
  935. hardware. See the section "Where to Find POV-Ray Files" for where to find
  936. these files. You can contact those sources to find out what the best version
  937. is for you and your computer.
  938.  
  939. 2.3.7            Compiling POV-Ray
  940.  
  941. The following sections will help you to compile the portable C source code
  942. into a working executable version of POV-Ray. They are only for those people
  943. who want to compile a custom version of POV-Ray or to port it to an
  944. unsupported platform or compiler.
  945.  
  946. The first question you should ask yourself before proceeding is Do  I really
  947. need to compile POV-Ray at all? Official POV-Ray Team executable versions are
  948. available for MS-DOS, Windows 3.1x/95/NT, Mac 68k, Mac Power PC, Amiga, Linux
  949. for Intel x86, and SunOS. Other unofficial compiles may soon be available for
  950. other platforms. If you do not intend to add any custom or experimental
  951. features to the program and if an executable already exists for your platform
  952. then you need not compile this program yourself.
  953.  
  954. If you do want to proceed you should be aware that you are very nearly on
  955. your own. The following sections and other related compiling documentation
  956. assume you know what you are doing. It assumes you have an adequate C
  957. compiler installed and working. It assumes you know how to compile and link
  958. large, multi-part programs using a make utility or an IDE project file if
  959. your compiler supports them. Because makefiles and project files often
  960. specify drive, directory or path information, we cannot promise our makefiles
  961. or projects will work on your system. We assume you know how to make changes
  962. to makefiles and projects to specify where your system libraries and other
  963. necessary files are located.
  964.  
  965. In general you should not expect any technical support from the POV-Ray Team
  966. on how to compile the program. Everything is provided here as is. All we can
  967. say with any certainty is that we were able to compile it on our systems. If
  968. it doesn't work for you we probably cannot tell you why.
  969.  
  970. There is no technical documentation for the source code itself except for the
  971. comments in the source files. We try our best to write clear, well- commented
  972. code but some sections are barely commented at all and some comments may be
  973. out dated. We do not provide any technical support to help you to add
  974. features. We do not explain how a particular feature works. In some
  975. instances, the person who wrote a part of the program is no longer active in
  976. the Team and we don't know exactly how it works.
  977.  
  978. When making any custom version of POV-Ray or any unofficial compile, please
  979. make sure you read and follow all provisions of our license in "Copyright".
  980. In general you can modify and use POV-Ray on your own however you want but if
  981. you distribute your unofficial version you must follow our rules. You may not
  982. under any circumstances use portions of POV-Ray source code in other
  983. programs.
  984.  
  985. 2.3.7.1          Directory Structure
  986.  
  987. POV-Ray source code is distributed in archives with files arranged in a
  988. particular hierarchy of directories or folders. When extracting the archives
  989. you should do so in a way that keeps the directory structure intact. In
  990. general we suggest you create a directory called povray3 and extract the
  991. files from there. The extraction will create a directory called source with
  992. many files and sub-directories.
  993.  
  994. In general, there are separate archives for each hardware platform and
  995. operating system but each of these archives may support more than one
  996. compiler. For example here is the directory structure for the MS-DOS archive.
  997.  
  998.  
  999.   SOURCE
  1000.   SOURCE\LIBPNG
  1001.   SOURCE\ZLIB
  1002.   SOURCE\MSDOS
  1003.   SOURCE\MSDOS\PMODE
  1004.   SOURCE\MSDOS\BORLAND
  1005.   SOURCE\MSDOS\DJGPP
  1006.   SOURCE\MSDOS\WATCOM
  1007.  
  1008.  
  1009. The source directory contains source files for the generic parts of POV-Ray
  1010. that are the same on all platforms. The source\libpng contains files for
  1011. compiling a library of routines used in reading and writing PNG (Portable
  1012. Network Graphics) image files. The source\zlib contains files for compiling a
  1013. library of routines used by libpng to compress and uncompress data streams.
  1014. All of these files are used by all platforms and compilers. They are in every
  1015. version of the source archives.
  1016.  
  1017. The source\msDOS directory contains all source files for the MS-DOS version
  1018. common to all supported MS-DOS compilers. The pmode sub-directory contains
  1019. source files for pmode.lib which is required by all MS-DOS versions. The
  1020. borland, djgpp, and watcom sub-directories contain source, makefiles and
  1021. project files for C compilers by Borland, DJGPP and Watcom.
  1022.  
  1023. The source\msDOS directory is only in the MS-DOS archive. Similarly the
  1024. Windows archive contains a source\windows directory. The Unix archive
  1025. contains source/unix etc.
  1026.  
  1027. The source\msDOS directory contains a file cmpl_msd.doc which contains
  1028. compiling information specific to the MS-DOS version. Other platform specific
  1029. directories contain similar cmpl_xxx.doc files and the compiler specific
  1030. sub-directories also contain compiler specific cmpl_xxx.doc files. Be sure to
  1031. read all pertinent cmpl_xxx.doc files for your platform and compiler.
  1032.  
  1033. 2.3.7.2          Configuring POV-Ray Source
  1034.  
  1035. Every platform has a header file config.h that is generally in the platform
  1036. specific directory but may be in the compiler specific directory. Some
  1037. platforms have multiple versions of this file and you may need to copy or
  1038. rename it as config.h. This file is included in every module of POV-Ray. It
  1039. contains any prototypes, macros or other definitions that may be needed in
  1040. the generic parts of POV-Ray but must be customized for a particular platform
  1041. or compiler.
  1042.  
  1043. For example different operating systems use different characters as a
  1044. separator between directories and file names. MS-DOS uses back slash, Unix a
  1045. front slash or Mac a colon. The config.h file for MS-DOS and Windows contains
  1046. the following:
  1047.  
  1048.   #define FILENAME_SEPARATOR ''
  1049.  
  1050.  
  1051. which tells the generic part of POV-Ray to use a back slash.
  1052.  
  1053. Every customization that the generic part of the code needs has a default
  1054. setting in the file source\frame.h which is also included in every module
  1055. after config.h. The frame.h header contains many groups of defines such as
  1056. this:
  1057.  
  1058.   #ifndef FILENAME_SEPARATOR
  1059.   #define FILENAME_SEPARATOR '/'
  1060.   #endif
  1061.  
  1062.  
  1063. which basically says if we didn't define this previously in config.h then
  1064. here's a default value. See frame.h to see what other values you might wish
  1065. to configure.
  1066.  
  1067. If any definitions are used to specify platform specific functions you should
  1068. also include a prototype for that function. The file source\msDOS\config.h,
  1069. for example, not only contains the macro:
  1070.  
  1071.   #define POV_DISPLAY_INIT(w,h) MSDOS_Display_Init ((w), (h));
  1072.  
  1073.  
  1074. to define the name of the graphics display initialization function, it
  1075. contains the prototype:
  1076.  
  1077.   void MSDOS_Display_Init (int w, int h);
  1078.  
  1079.  
  1080. If you plan to port POV-Ray to an unsupported platform you should probably
  1081. start with the simplest, non-display generic Unix version. Then add new
  1082. custom pieces via the config.h file.
  1083.  
  1084. 2.3.7.3          Conclusion
  1085.  
  1086. We understand that the above sections are only the most trivial first steps
  1087. but half the fun of working on POV-Ray source is digging in and figuring it
  1088. out on your own. That's how the POV-Ray Team members got started. We've tried
  1089. to make the code as clear as we can.
  1090.  
  1091. Be sure to read the cmpl_xxx.doc files in your platform specific and compiler
  1092. specific directories for some more minor help if you are working on a
  1093. supported platform or compiler.
  1094.  
  1095.  
  1096. 2.4              Where to Find POV-Ray Files
  1097.  
  1098. The latest versions of the POV-Ray software are available from the following
  1099. sources.
  1100.  
  1101. 2.4.1            POV-Ray Forum on CompuServe
  1102.  
  1103. The headquarters of POV-Ray are on CompuServe in the POVRAY forum, that is
  1104. managed by some of the team members. We meet there to share information,
  1105. useful programs and utilities and graphics created by POV-Ray. Everyone is
  1106. welcome to join in on the action on CIS:POVRAY. Hope to see you there! You
  1107. can get information on joining CompuServe by calling (800)848-8990 or visit
  1108. the CompuServe home page http://www.compuserve.com. Direct CompuServe access
  1109. is also available in Japan, Europe and many other countries.
  1110.  
  1111. 2.4.2            Internet
  1112.  
  1113. The internet home of POV-Ray is reachable on the World Wide Web via the
  1114. address http://www.povray.org and via ftp as ftp.povray.org. Please stop by
  1115. often for the latest files, utilities, news and images from the official
  1116. POV-Ray internet site.
  1117.  
  1118. The comp.graphics.rendering.raytracing newsgroup has many competent POV-Ray
  1119. users that are very willing to share their knowledge. They generally ask that
  1120. you first browse a few files to see if someone has already answered the same
  1121. question, and of course, that you follow proper "netiquette". If you have any
  1122. doubts about the qualifications of the folks that frequent the group, a few
  1123. minutes spend at the Ray Tracing Competition pages at www.povray.org will
  1124. quickly convince you!
  1125.  
  1126. 2.4.3            PC Graphics Area on America On-Line
  1127.  
  1128. There's an area now on America On-Line dedicated to POV-Ray support and
  1129. information. You can find it in the PC Graphics section of AOL. Jump keyword
  1130. POV (the keyword PCGRAPHICS brings you to the top of the graphics related
  1131. section). This area includes the Apple Macintosh executables also. It is best
  1132. if messages are left in the Company Support section. Currently, Bill Pulver
  1133. (BPulver) is our representative there.
  1134.  
  1135. 2.4.4            The Graphics Alternative BBS in El Cerrito, CA
  1136.  
  1137. For those on the West coast, you may want to find the POV-Ray files on The
  1138. Graphics Alternative BBS. It's a great graphics BBS run by Adam Shiffman. TGA
  1139. is high quality, active and progressive BBS system which offers both quality
  1140. messaging and files to its 1300+ users.
  1141.  
  1142.   510-524-2780 (PM14400FXSA v.32bis 14.4k, Public)
  1143.   510-524-2165 (USR DS v.32bis/HST 14.4k, Subscribers)
  1144.  
  1145.  
  1146. 2.4.5            PCGNet
  1147.  
  1148. The Professional CAD and Graphics Network (PCGnet) serves both the CAD and
  1149. Graphics communities by making information useful to them widely available.
  1150.  
  1151. Formerly known as ADEnet, PCGnet is a new network created from the ground up,
  1152. incorporating new nodes and focusing evenly on both CAD and graphics related
  1153. topics, including, but not limited to the following topics: design, drafting,
  1154. engineering, 2d and 3d modeling, multimedia, systems, raster imaging,
  1155. raytracing, 3d rendering and animation.
  1156.  
  1157. PCGnet is designed to serve the needs of all callers by stimulating interest
  1158. and generating support forums for active users who have an interest in the
  1159. CAD and graphics related topics previously mentioned; interest and support is
  1160. generated through PCGnet's message conferences, file sharing across the
  1161. network, and industry news and press releases. PCGnet's message conference
  1162. are moderated forums designed to accommodate friendly, yet professional and
  1163. informative discussion of CAD and graphics related subjects.
  1164.  
  1165. TGA BBS serves as the central hub for a large network of graphics-oriented
  1166. BBS systems around the world. Following is a concise listing of active PCGNet
  1167. nodes at the time of this writing. The POV-Team can not vouch for the
  1168. currency of this information, nor verify that any of these boards may carry
  1169. POV-Ray.
  1170.  
  1171. USA and Canada
  1172.   411-Exchange                 Alpharetta        GA      404-345-0008
  1173.   Autodesk Global Village      San Rafael        CA      415-507-5921
  1174.   CAD/Engineering Services     Hendersonville    TN      615-822-2539
  1175.   Canis Major                  Nashville         TN      615-385-4268
  1176.   CEAO BBS                     Columbus          OH      614-481-3194
  1177.   CHAOS BBS                    Columbia          MO      314-874-2930
  1178.   Joes CODE BBS                West Bloomfield   MI      810-855-0894
  1179.   John's Graphics              Brooklyn Park     MN      612-425-4436
  1180.   PC-AUG                       Phoenix           AZ      602-952-0638
  1181.   SAUG BBS                     Bellevue          WA      206-644-7115
  1182.   Space Command BBS            Kennewick         WA      509-735-4894
  1183.   The CAD/fx BBS               Mesa              AZ      602-835-0274
  1184.   The Drawing Board BBS        Anchorage         AK      907-349-5412
  1185.   The Graphics Alternative     El Cerrito        CA      510-524-2780
  1186.   The Happy Canyon             Denver            CO      303-759-3598
  1187.   The New Graphics BBS         Piscataway        NJ      908-271-8878
  1188.   The University               Shrewsbury Twp    NJ      908-544-8193
  1189.   The Virtual Dimension        Oceanside         CA      619-722-0746
  1190.   Time-Out BBS                 Sadsburyville     PA      610-857-2648
  1191.  
  1192. Australia
  1193.   MULTI-CAD Magazine BBS       Toowong QLD              61-7-878-2940
  1194.   My Computer Company          Erskineville NSW         61-2-557-1489
  1195.   Sydney PCUG Compaq BBS       Caringbah NSW            61-2-540-1842
  1196.   The Baud Room                Melbourne VIC            61-3-481-8720
  1197.  
  1198. Austria
  1199.   Austrian AutoCAD User Group  Graz                    43-316-574-426
  1200.  
  1201. Belgium
  1202.   Lucas Visions BBS            Boom                     32-3-8447-229
  1203.  
  1204. Denmark
  1205.   Horreby SuperBBS             Nykoebing Falster        45-53-84-7074
  1206.  
  1207. Finland
  1208.   DH-Online                    Jari Hiltunen           358-9-40562248
  1209.   Triplex BBS                  Helsinki                358-9-5062277
  1210.  
  1211. France
  1212.   CAD Connection               Montesson                33-1-39529854
  1213.   Zyllius BBS!                 Saint Paul                 33-93320505
  1214.  
  1215. Germany
  1216.   Ray BBS Munich               Munich                    49-89-984723
  1217.   Tower of Magic               Gelsenkirchen            49-209-780670
  1218.  
  1219. Netherlands
  1220.   BBS Bennekom: Fractal Board  Bennekom                 31-318-415331
  1221.   CAD-BBS                      Nieuwegein               31-30-6090287
  1222.                                                         31-30-6056353
  1223.   Foundation One               Baarn                    31-35-5422143
  1224.  
  1225. New Zealand
  1226.   The Graphics Connection      Wellington               64-4-566-8450
  1227.   The Graphics Connection II   New Plymouth             64-6-757-8092
  1228.   The Graphics Connection III  Auckland                 64-9-309-2237
  1229.  
  1230. Slovenia
  1231.   MicroArt                     Koper                     386-66-34986
  1232.  
  1233. Sweden
  1234.   Autodesk On-line             Gothenburg                46-31-401718
  1235.  
  1236. United Kingdom
  1237.   CADenza BBS                  Leicester, UK          44-116-259-6725
  1238.   Raytech BBS                  Tain, Scotland         44-1862-83-2020
  1239.   The Missing Link             Surrey, England        44-181-641-8593
  1240.  
  1241.  
  1242. Country or long distance dial numbers may require additional numbers to be
  1243. used. Consult your local phone company.
  1244.  
  1245. 2.4.6            POV-Ray Related Books and CD-ROMs
  1246.  
  1247. The following items were produced by POV-Team members. Although they are only
  1248. current to POV-Ray 2.2 they will still be helpful. Steps are being taken to
  1249. update the POV-Ray CDROM to version 3.0, with a new version expected around
  1250. October 1996.
  1251.  
  1252. The books listed below have been recently listed as out-of-print but may
  1253. still be found in some bookstores or libraries (Visit
  1254. http://www.dnai.com:80/waite/ for more details).
  1255.  
  1256.   Ray Tracing Creations, 2d Ed.
  1257.   Chris Young and Drew Wells
  1258.   ISBN 1-878739-69-7
  1259.   Waite Group Press 1994
  1260.     700 pages with color insert and POV-Ray 2.2 on 3.5" MS-DOS disk.
  1261.  
  1262.   Ray Tracing Worlds with POV-Ray
  1263.   Alexander Enzmann, Lutz Kretzschmar, Chris Young,
  1264.   ISBN 1-878739-64-6
  1265.   Waite Group Press 1994
  1266.     Includes Moray 1.5x modeller and POV-Ray 2.2 on 3.5" MS-DOS disks.
  1267.  
  1268.   Ray Tracing for the Macintosh CD
  1269.   Eduard Schwan
  1270.   ISBN 1-878739-72-7
  1271.   Waite Group Press, 1994
  1272.     Comes with a CD-ROM full of scenes, images, and QuickTime movies,
  1273.     and an interactive keyword reference. Also a floppy with POV-Ray for
  1274.     those who don't have a CD ROM drive.
  1275.  
  1276.  
  1277. 'The Official POV-Ray CDROM' The Official POV-Ray CDROM: The Official POV-Ray
  1278. CDROM is a compilation of images, scene source, program source, utilities and
  1279. tips on POV-Ray and 3D graphics from the Internet and Compuserve. This CD is
  1280. aimed not only at those who want to create their own images or do general 3D
  1281. programming work, but also at those who want simply to experience some
  1282. high-quality renderings done by some of the best POV-Ray artists, and to
  1283. learn from their source code. The CDROM contains over 500 ray-traced images.
  1284.  
  1285. It's a good resource for those learning POV-Ray as well as those who are
  1286. already proficient, and contains a Microsoft Windows-based interactive
  1287. tutorial. The disk comes with a fold-out poster and reference sheet. The CD
  1288. is compatible with DOS/Windows and Macintosh formats.
  1289.  
  1290. The CDROM is available for free retrieval and browsing on the World Wide Web
  1291. at http://www.povray.org/pov-cdrom. For more details you may also visit
  1292. http://www.povray.org/povcd.
  1293.  
  1294. 3                Quick Start
  1295.  
  1296. The next section describes how to quickly install POV-Ray and render sample
  1297. scenes on your computer. It is assumed that you are using an IBM-PC
  1298. compatible computer with MS-DOS. For other platforms you must refer to the
  1299. specific documentation included in archive that contains POV-Ray.
  1300.  
  1301. 3.1              Installing POV-Ray
  1302.  
  1303. Specific installation instructions are included with the executable program
  1304. for your computer. In general, there are two ways to install POV-Ray.
  1305.  
  1306. [ Note that the generic word "directory" is used throughout. Your operating
  1307. system may use another word (subdirectory, folder, etc.) ]
  1308.  
  1309. 1) The messy way: Create a directory called POVRAY and copy all POV-Ray files
  1310. into it. Edit and run all files and programs from this directory. This method
  1311. works, but is not recommended.
  1312.  
  1313. Or the preferred way:
  1314.  
  1315. 2) Create a directory called POVRAY and several subdirectories called
  1316. INCLUDE, DEMO, SCENES, UTIL. The self-extracting archives used in some
  1317. versions of the program will create subdirectories for you. If you create
  1318. your own, the file tree for this should look something like this:
  1319.  
  1320.     \--
  1321.       |
  1322.       +POVRAY --
  1323.                |
  1324.                +INCLUDE
  1325.                |
  1326.                +DEMO
  1327.                |
  1328.                +SCENES
  1329.                |
  1330.                +UTIL
  1331.  
  1332.  
  1333. Copy the executable file and docs into the directory POVRAY. Copy the
  1334. standard include files into the subdirectory INCLUDE. Copy the sample scene
  1335. files into the subdirectory SCENES. And copy any POV-Ray related utility
  1336. programs and their related files into the subdirectory UTIL. Your own scene
  1337. files will go into the SCENES subdirectory. Also, you'll need to add the
  1338. directories \POVRAY and \POVRAY\UTIL to your "search path" so the executable
  1339. programs can be run from any directory.
  1340.  
  1341. Note that some operating systems don't have an equivalent to the multi-path
  1342. search command.
  1343.  
  1344. The second method is a bit more difficult to set-up, but is preferred. There
  1345. are many files associated with POV-Ray and they are far easier to deal with
  1346. when separated into several directories.
  1347.  
  1348. 3.2              Basic Usage
  1349.  
  1350. Notice: If you did not install the program using the install.exe system, the
  1351. examples and instructions given here may not work! The installation process
  1352. configures povray.ini and several important batch files. Without these files
  1353. configured, the examples herein may not work.
  1354.  
  1355. POV-Ray's basic purpose is to read a scene description written in the POV
  1356. language and to write an image file. The scene files are plain ASCII text
  1357. files that you create using a text editor. Dozens of sample files are
  1358. included with this package to illustrate the various features.
  1359.  
  1360. You invoke POV-Ray by typing a command at the MS-DOS prompt. The command is
  1361. povray and it must be followed by one or more command line switches. Each
  1362. switch begins with a plus or minus sign. Blanks separate the switches. The
  1363. switches may be upper or lower case.
  1364.  
  1365. Note: The examples in this documentation assume you installed POV-Ray in the
  1366. c:\povray3 directory. The installer will let you install POV-Ray anywhere and
  1367. will properly configure it for the drive and directory you specified. You
  1368. just substitute that drive and directory anywhere we tell you to use
  1369. c:\povray3. Change to that directory now. Then type the following command
  1370. line and press [ENTER]
  1371.  
  1372.   POVRAY +ISHAPES +D1
  1373.  
  1374.  
  1375. The +I command (for input) tells the program what file to read as input. If
  1376. you don't give an extension on the file name, .pov is assumed. Thus +Ishapes
  1377. tells it to read in shapes.pov to be rendered.
  1378.  
  1379. The +D switch (for display) tells the program to turn the graphic preview
  1380. display on. A -D would turn it off. The number "1" tells it what type of
  1381. display to use. Type "1" is the old fashioned standard generic VGA at 320 by
  1382. 200 resolution and just 256 colors. This is pretty much guaranteed to work on
  1383. any VGA video system.
  1384.  
  1385. There are other options in effect besides those you typed on the command
  1386. line. They are stored in a file called povray.ini which was created by the
  1387. install system. POV-Ray automatically looks for this file in the same
  1388. directory where povray.exe resides. See "INI Files" and "Using INI Files" for
  1389. more information on povray.ini and other INI files.
  1390.  
  1391. When you enter the command shown above, you will see brightly colored
  1392. geometric shapes begin to appear as POV-Ray calculates the color of each
  1393. pixel row by row. You will probably be disappointed with the graphic display
  1394. results. That is because this is only a preview display. The actual image is
  1395. in full 24-bit color but we cannot display that high quality using simple VGA
  1396. with a fixed set of 256 colors. If your hardware supports the VESA interface
  1397. standard or you have a VESA TSR driver loaded, try running with +DG rather
  1398. than +D1. This will give you access to all of the various modes your video
  1399. hardware can use. If you have 15-bit or 16- bit high color capability try
  1400. +DGH or if you have 24-bit true color capability try +DGT to see the image in
  1401. all its glory. See section "Display Types" below for more information on
  1402. graphics preview.
  1403.  
  1404. When the program finishes, you will hear beeps. After admiring the image,
  1405. press [ENTER]. You will see a text screen of statistics. If the text is too
  1406. much to fit on the screen you may press [CURSOR UP] or [CURSOR DOWN] keys to
  1407. read more text. Notice that there are tabs at the bottom of the screen. Press
  1408. [CURSOR LEFT] or [CURSOR RIGHT] keys to view other interesting text
  1409. information. Press [ENTER] again to exit POV-Ray.
  1410.  
  1411. If you do not have high color or true color ability you will have to view the
  1412. image file to see the real colors. The image file shapes.tga is written to
  1413. your current directory. By default POV-Ray creates files in TGA format. This
  1414. is a standard format for storing 24-bit true-color images. You will need an
  1415. image viewing program to view the file. Such programs are usually available
  1416. from the same place where you obtained POV-Ray but a viewer is not included
  1417. in this package.
  1418.  
  1419. If you cannot view TGA files you may add the switch +FN and POV-Ray will
  1420. output PNG (Portable Network Graphic) format. If PNG format viewer is not
  1421. available then type the following
  1422.  
  1423.   T2G SHAPES
  1424.  
  1425.  
  1426. and press [ENTER]. This will run a batch file that invokes the tga2gif
  1427. program. The program will read your shapes.tga file, create an optimal 256
  1428. color palette and write a GIF format file shapes.gif. Most image viewing
  1429. programs support GIF.
  1430.  
  1431. 3.2.1            Running Files in Other Directories
  1432.  
  1433. Normally POV-Ray only looks in the current directory for the files it needs.
  1434. It does not search your MS-DOS path for data files; it only searches for
  1435. programs. In the sample scene you just ran, file shapes.pov was in the
  1436. current directory so this was no problem. That scene also needed other files
  1437. but your povray.ini file tells POV-Ray other places to search for necessary
  1438. files.
  1439.  
  1440. If you allowed the install system to update your autoexec.bat file, then you
  1441. can change to any drive or directory and can run POV-Ray from that directory.
  1442. You will also be able to use the batch files and utilities that came with
  1443. this package in any directory. For future reference let's call the
  1444. "use-c:\povray3-in-your-path-plan" as plan one.
  1445.  
  1446. There are some circumstances where you may not want to put c:\povray3 in your
  1447. path. There is a limit of 128 characters in your path statement and you may
  1448. not have room for it. Try rendering the shapes example from a different
  1449. directory. If it doesn't work, then you forgot to re-boot your system so the
  1450. new path takes effect. If after re-booting it still doesn't work, it probably
  1451. means your path is too full. You will have to adopt a different plan.
  1452.  
  1453. Chances are, you already have several directories in your path. Most systems
  1454. have c:\DOS, c:\windows or some directory such as c:\utility already in the
  1455. path. We have provided several small batch files that you can copy to that
  1456. directory. For future reference we'll call the
  1457. "put-batch-files-in-a-directory-already-on-the-path-plan" as plan  two.
  1458.  
  1459. At any DOS prompt, type the word path and press [ENTER]. It will show you
  1460. what directories are already on your path. Then copy the following files from
  1461. your c:\povray3 directory to any of the directories already on your path. The
  1462. files are:
  1463.  
  1464.   RUNPOV.BAT RERUNPOV.BAT RUNPHELP.BAT T2G.BAT
  1465.  
  1466.  
  1467. Once you have copied these files, try the following example. In this case, do
  1468. not invoke the program with the command povray. Instead use runpov as
  1469. follows:
  1470.  
  1471.   cd \POVRAY3\POV3DEMO\SHOWOFF
  1472.   RUNPOV +ISUNSET3 +D1
  1473.  
  1474.  
  1475. This changes to the \povray3\pov3demo\showoff directory where the file
  1476. sunset3.pov is found. It runs the file runpov.bat. That batch file is set up
  1477. to run POV-Ray even if it is not on the DOS path. It also passes the switches
  1478. along to POV-Ray. These batch files have other uses, even if you are using
  1479. plan one as described above or plan three as described below. For more on
  1480. these batch files, see "Batch Files".
  1481.  
  1482. All of the early examples in this document assumed you were running POV-Ray
  1483. from the directory where it was installed such as c:\povray3. This approach
  1484. of always using the installation directory is in fact plan three. If you are
  1485. using this method, you need to tell POV-Ray where else to look for files. In
  1486. the case of sunset3.pov you could do this:
  1487.  
  1488.   POVRAY +IC:\POVRAY3\POV3DEMO\SHOWOFF\SUNSET3 +D1
  1489.  
  1490.  
  1491. However some scenes need more than one file. For example the directory drums2
  1492. that can be found under \povray3\povscn\level3 contains three files:
  1493. drums.pov, drums.inc and rednewt.gif all of which are required for that one
  1494. scene. In this case you should use the +L switch (for library) to add new
  1495. library paths to those that POV-Ray will search. You would render the scene
  1496. with this command.
  1497.  
  1498.   POVRAY +L\POVRAY3\POVSCN\LEVEL3\DRUMS2 +IDRUMS +D1
  1499.  
  1500.  
  1501. 3.2.2            INI Files
  1502.  
  1503. There were more options used in these renderings than just the switches +I,
  1504. +D, and +L that you specify. When you run the program, POV- Ray automatically
  1505. looks for the file povray.ini in whatever directory that povray.exe is in.
  1506. The povray.ini file contains many options that control how POV-Ray works. We
  1507. have set this file up so that it is especially easy to run your first scene
  1508. with minimal problems. The file should be placed in the same directory as
  1509. povray.exe and it will automatically read when POV-Ray is run. If you ever
  1510. move povray.exe to a different directory, be sure to move povray.ini too.
  1511.  
  1512. Complete details on all of the available switches and options that can be
  1513. given on the command line or in povray.ini are given in "POV-Ray Options".
  1514.  
  1515. You may also create INI files of your own with switches or options similar to
  1516. povray.ini. If you put a file name on the command line without a plus or
  1517. minus sign before it, POV-Ray reads it as an INI file. Try this...
  1518.  
  1519.   POVRAY RES120 +ISHAPES +D1
  1520.  
  1521.  
  1522. This causes POV-Ray to look for a file called res120.ini which we have
  1523. provided. It sets your resolution to 120 by 90 pixels for a quick preview.
  1524. The following INI files have been provided for you.
  1525.  
  1526.   SLOW.INIII           Turns on radiosity and anti-aliasing; very slow but
  1527.   ZIPFLI.INI ZIPFLC.INICreate an FLI/FLC animation from zipped images. See
  1528.                        "ANIMATION TIPS" below.
  1529.  
  1530.  
  1531. You can create your own custom INI's which can contain any command in the
  1532. reference guide.
  1533.  
  1534. 3.2.3            Alternatives to POVRAY.INI
  1535.  
  1536. The povray.ini file is supposed to hold your favorite global default options
  1537. that you want to use all the time. You should feel free to edit it with new
  1538. options that suit your needs. However it must be located in the same
  1539. directory as povray.exe or it won't be found. The DOS path isn't searched nor
  1540. will +L commands help because povray.ini is processed before any command line
  1541. switches.
  1542.  
  1543. If your povray.exe resides on a CD-ROM then you can't edit the povray.ini on
  1544. the CD. There is an alternative. You may use an environment variable to
  1545. specify an alternative global default.
  1546.  
  1547. In your autoexec.bat file add a line similar to this:
  1548.  
  1549.   set POVINI=D:\DIRECT\FILE.INI
  1550.  
  1551.  
  1552. which sets the POVINI environment variable to whatever drive, directory and
  1553. INI file you choose. If you specify any POVINI environment variable then
  1554. povray.ini is not read. This is true even if the file you named doesn't
  1555. exist. Note that you are specifying an entire path and file name. This is not
  1556. a pointer to a directory containing povray.ini. It is a pointer to the actual
  1557. file itself.
  1558.  
  1559. Note that the POVRAYOPT environment variable in previous versions of POV-Ray
  1560. is no longer supported.
  1561.  
  1562. 3.2.4            Batch Files
  1563.  
  1564. We've already described how the file runpov.bat can be used as an alternative
  1565. to running POV-Ray directly. runpov.bat also has one other use. It uses the
  1566. +GI switch to create a file called rerun.ini. This makes it very easy to run
  1567. the same file over again with the same parameters. When creating your own
  1568. scene files you will probably make dozens of test renders. This is a very
  1569. valuable feature. Here is how it works... Suppose you render a scene as
  1570. follows:
  1571.  
  1572.   RUNPOV +IMYSCENE +D1 RES120
  1573.  
  1574.  
  1575. This renders myscene.pov at 120 by 90 resolution. Note there is no such
  1576. scene. This is hypothetical. After viewing it, you noticed a mistake which
  1577. you fixed with your text editor. To rerun the scene type:
  1578.  
  1579.   RERUNPOV
  1580.  
  1581.  
  1582. and that's all. It will rerun the same scene you just ran. Suppose you want
  1583. more detail on the next run. You can add more switches or INI files. For
  1584. example:
  1585.  
  1586.   RERUNPOV RES320
  1587.  
  1588.  
  1589. will rerun at higher resolution. Subsequent uses of rerunpov will be at 320
  1590. by 200 until you tell it differently. As another example, the +A switch turns
  1591. on anti-aliasing. Typing "rerunpov +A" reruns with anti- aliasing on. All
  1592. subsequent reruns will have it on until you do a "rerunpov -A" to turn it
  1593. off. Note if you do another runpov it starts over from your povray.ini
  1594. defaults and it overwrites the old rerun.ini.
  1595.  
  1596. Two other batch files are included. runphelp.bat is only used as an
  1597. alternative way to run povhelp from another directory. If you used
  1598. installation plan two then use runphelp.bat rather than povhelp.exe. This
  1599. batch file serves no other purpose.
  1600.  
  1601. Finally t2g.bat invokes the tga2gif.exe program for converting TGA files to
  1602. GIF files. You could run \FILE {tga2gif} directly but its default parameters
  1603. do not generally produce the best results. If you use T2G instead, it adds
  1604. some command line switches which work better. For a full list of switches
  1605. available for tga2gif, type tga2gif with no parameters and it will display
  1606. the available switches and options.
  1607.  
  1608. 3.2.5            Display Types
  1609.  
  1610. You have already seen how to turn on graphics preview using +D1. Here are
  1611. details on other variations of the +D switch. Use -D to turn the display off.
  1612. If you use -D then you will probably want to add the +V switch to turn on
  1613. verbose status messages so you can monitor the progress of the rendering
  1614. while in progress.
  1615.  
  1616. The number "1" after the +D tells it what kind of video hardware to use. If
  1617. you use +D alone or +D0 then POV-Ray will attempt to auto detect your
  1618. hardware type. Use +D? to see a message about what type of hardware POV-Ray
  1619. found.
  1620.  
  1621. You may also explicitly tell POV-Ray what hardware to use. The following
  1622. chart lists all of the supported types.
  1623.  
  1624.   +DIDiamond Computer Systems SpeedSTAR 24X
  1625.  
  1626.  
  1627. The most common type is a VESA standard card which uses +DG. VESA is a
  1628. standard software interface that works on a wide variety of cards. Those
  1629. cards which do not have VESA support directly built-in, generally have a
  1630. video driver that you can load to provide VESA support. The program UniVBE is
  1631. a high quality universal VESA driver that may work for you. It can be found
  1632. at http://www.povray.org or possibly other POV-Ray sites.
  1633.  
  1634. The options listed above had been tested worked under earlier versions of
  1635. POV-Ray but there have been many changes in the program and we cannot
  1636. guarantee these all still work. If you can use VESA then do so. It has been
  1637. well tested and will give you the most flexibility.
  1638.  
  1639. After the +D and the type, you may specify a 3rd character that specifies the
  1640. palette type.
  1641.  
  1642.   +D?3Use 332 palette with dithering (default and best for VGA systems). This
  1643.       is a fixed palette of 256 colors with each color consisting 3-bits of
  1644.   +D?0Use HSV palette option for VGA display. This is a fixed palette of 256
  1645.       colors where colors are matched according to hue, saturation and
  1646.   +D?HUse HiColor option. Displays more than 32,000 colors with dithering.
  1647.       Supported on VESA, SpeedSTAR 24X, ATI XL HiColor and Tseng 4000 based
  1648.   +D?TFor Truecolor 24 bit cards. Use 24 bit color. Supported on the Diamond
  1649.       SpeedSTAR 24X and cards with 24-bit VESA support only.
  1650.  
  1651.  
  1652. Here are some examples:
  1653.  
  1654.    +D0H Auto detect the VGA display type and display the image to the
  1655.         screen as it's being worked on. Use the 15-bit HiColor chip and
  1656.         dithering to display more than 32,000 colors on screen.
  1657.    +D4  Display to a TSENG 4000 chipset VGA using the 332 palette option.
  1658.    +D4H Display to a TSENG 4000 chipset VGA using the HiColor option.
  1659.    +DG0 Display to a VESA VGA adapter and use the HSV palette option.
  1660.    +DG3 Display to a VESA VGA adapter and use the 332 palette option.
  1661.    +DGH Display to a VESA VGA adapter and use the HiColor option for
  1662.         over 32,000 colors.
  1663.    +DGT Display to a VESA VGA adapter and use the TrueColor option for
  1664.         over 16 million colors.
  1665.  
  1666.  
  1667. Note that your VESA BIOS must support these options in order for you to use
  1668. them. Some cards may support HiColor and/or TrueColor at the hardware level
  1669. but not through their VESA BIOS.
  1670.  
  1671. 4                Beginning Tutorial
  1672.  
  1673. The beginning tutorial explains step by step how to use POV-Ray's scene
  1674. description language to create own scenes. The use of almost every feature of
  1675. POV-Ray's language is explained in detail. We will learn basic things like
  1676. placing cameras and light sources. We will also learn how to create a large
  1677. variety of objects and how to assign different textures to them. The more
  1678. sophisticated features like radiosity, halos and atmospheric effects will be
  1679. explained in detail.
  1680.  
  1681. The following sections explain the features in roughly the same order as they
  1682. are described in the reference guide.
  1683.  
  1684. 4.1              Our First Image
  1685.  
  1686. We will create the scene file for a simple picture. Since ray-tracers thrive
  1687. on spheres, that is what we will render first.
  1688.  
  1689. 4.1.1            Understanding POV-Ray's Coordinate System
  1690.  
  1691. First, we have to tell POV-Ray where our camera is and where it is looking.
  1692. To do this, we use 3D coordinates. The usual coordinate system for POV-Ray
  1693. has the positive y-axis pointing up, the positive x-axis pointing to the
  1694. right, and the positive z-axis pointing into the screen as follows:
  1695.  
  1696.           ^+Y
  1697.           |   /+Z
  1698.           |  /
  1699.           | /
  1700.   -X      |/        +X
  1701.   <-------|-------->
  1702.          /|
  1703.         / |
  1704.        /  |
  1705.     -Z/   |
  1706.           v-Y
  1707. The left-handed coordinate system (the z-axis is pointing away).
  1708.  
  1709. This kind of coordinate system is called a left-handed coordinate system. If
  1710. we use our left hand's fingers we can easily see why it is called
  1711. left-handed. We just point our thumb in the direction of the positive x-axis,
  1712. the index finger in the direction of the positive y-axis and the middle
  1713. finger in the positive z-axis direction. We can only do this with our left
  1714. hand. If we had used our right hand we would not have been able to point the
  1715. middle finger in the correct direction.
  1716.  
  1717. The left hand can also be used to determine rotation directions. To do this
  1718. we must perform the famous Computer Graphics Aerobics exercise. We hold up
  1719. our left hand and point our thumb in the positive direction of the axis of
  1720. rotation. Our fingers will curl in the positive direction of rotation.
  1721. Similarly if we point our thumb in the negative direction of the axis our
  1722. fingers will curl in the negative direction of rotation.
  1723.  
  1724.            ^
  1725.          +Y|   +Z/ _
  1726.            |    /_| |_  _
  1727.            |   _| | | |/ \
  1728.            |  | | | | |  |
  1729.            | /| | | | |  V
  1730.  -X        |/ | | | | |    +X
  1731. <----------+--|-|-|-|-|------>
  1732.           /|  |       ____
  1733.          / |  |         ___|
  1734.         /  |          /
  1735.        /   |   |      /
  1736.     -Z/  -Y|
  1737.      /     |
  1738. "Computer Graphics Aerobics" to determine the rotation direction.
  1739.  
  1740. In the above illustration, the left hand is curling around the x-axis. The
  1741. thumb points in the positive x direction and the fingers curl over in the
  1742. positive rotation direction.
  1743.  
  1744. If we want to use a right-handed system, as some CAD systems and modellers
  1745. do, the right vector in the camera specification needs to be changed. See the
  1746. detailed description in "Handedness". In a right-handed system we use our
  1747. right hand for the Aerobics.
  1748.  
  1749. There is some controversy over whether POV-Ray's method of doing a
  1750. right-handed system is really proper. To avoid problems we stick with the
  1751. left-handed system which is not in dispute.
  1752.  
  1753. 4.1.2            Adding Standard Include Files
  1754.  
  1755. Using our personal favorite text editor, we create a file called demo.pov. We
  1756. then type in the following text. The input is case sensitive, so we have to
  1757. be sure to get capital and lowercase letters correct.
  1758.  
  1759.   #include "colors.inc"    // The include files contain
  1760.   #include "shapes.inc"    // pre-defined scene elements
  1761.   #include "finish.inc"
  1762.   #include "glass.inc"
  1763.   #include "metals.inc"
  1764.   #include "stones.inc"
  1765.   #include "woods.inc"
  1766.  
  1767.  
  1768. The first include statement reads in definitions for various useful colors.
  1769. The second include statement reads in some useful shapes. The next read
  1770. pre-defined finishes, glass, metal, stone and wood textures. It is a good
  1771. idea to have a look through them to see but a few of the many possible shapes
  1772. and textures available.
  1773.  
  1774. We should only include files we really need in our scene. Some of the include
  1775. files coming with POV-Ray are quite large and we should better save the
  1776. parsing time and memory if we don't need them. In the following examples we
  1777. will only use the colors.inc, finish.inc and stones.inc include files so we
  1778. will better remove the appropriate lines from our scene file.
  1779.  
  1780. We may have as many include files as needed in a scene file. Include files
  1781. may themselves contain include files, but we are limited to declaring
  1782. includes nested only ten levels deep.
  1783.  
  1784. Filenames specified in the include statements will be searched for in the
  1785. current directory first and, if not found, will then be searched for in
  1786. directories specified by any +L or Library_Path options active. This would
  1787. facilitate keeping all our "include" (.inc) files such as shapes.inc,
  1788. colors.inc and textures.inc in an "include" subdirectory, and giving an +L
  1789. switch on the command line to where our library of include files are.
  1790.  
  1791. 4.1.3            Adding a Camera
  1792.  
  1793. The camera declaration describes where and how the camera sees the scene. It
  1794. gives x-, y- and z-coordinates to indicate the position of the camera and
  1795. what part of the scene it is pointing at. We describe the coordinates using a
  1796. three-part vector. A vector is specified by putting three numeric values
  1797. between a pair of angle brackets and separating the values with commas.
  1798.  
  1799. We add the following camera statement to the scene.
  1800.  
  1801.   camera {
  1802.     location <0, 2, -3>
  1803.     look_at  <0, 1,  2>
  1804.   }
  1805.  
  1806.  
  1807. Briefly, location <0,2,-3> places the camera up two units and back three
  1808. units from the center of the ray-tracing universe which is at <0,0,0>. By
  1809. default +z is into the screen and -z is back out of the screen.
  1810.  
  1811. Also look_at <0,1,2> rotates the camera to point at the coordinates <0,1,2>.
  1812. A point 5 units in front of and 1 unit lower than the camera. The look_at
  1813. point should be the center of attention of our image.
  1814.  
  1815. 4.1.4            Describing an Object
  1816.  
  1817. Now that the camera is set up to record the scene, let's place a yellow
  1818. sphere into the scene. We add the following to our scene file:
  1819.  
  1820.   sphere {
  1821.     <0, 1, 2>, 2
  1822.     texture {
  1823.       pigment { color Yellow }
  1824.     }
  1825.   }
  1826.  
  1827.  
  1828. The first vector specifies the center of the sphere. In this example the x
  1829. coordinate is zero so it is centered left and right. It is also at y=1 or one
  1830. unit up from the origin. The z coordinate is 2 which is five units in front
  1831. of the camera, which is at z=-3. After the center vector is a comma followed
  1832. by the radius which in this case is two units. Since the radius is half the
  1833. width of a sphere, the sphere is four units wide.
  1834.  
  1835. 4.1.5            Adding Texture to an Object
  1836.  
  1837. After we have defined the location and size of the sphere, we need to
  1838. describe the appearance of the surface. The texture block specifies these
  1839. parameters. Texture blocks describe the color, bumpiness and finish
  1840. properties of an object. In this example we will specify the color only. This
  1841. is the minimum we must do. All other texture options except color will use
  1842. default values.
  1843.  
  1844. The color we define is the way we want an object to look if fully
  1845. illuminated. If we were painting a picture of a sphere we would use dark
  1846. shades of a color to indicate the shadowed side and bright shades on the
  1847. illuminated side. However ray-tracing takes care of that. We pick the basic
  1848. color inherent in the object and POV-Ray brightens or darkens it depending on
  1849. the lighting in the scene. Because we are defining the basic color the object
  1850. actually has rather than how it looks the parameter is called pigment.
  1851.  
  1852. Many types of color patterns are available for use in a pigment statement.
  1853. The keyword color specifies that the whole object is to be one solid color
  1854. rather than some pattern of colors. We can use one of the color identifiers
  1855. previously defined in the standard include file colors.inc.
  1856.  
  1857. If no standard color is available for our needs, we may define our own color
  1858. by using the color keyword followed by red, green and blue keywords
  1859. specifying the amount of red, green and blue to be mixed. For example a nice
  1860. shade of pink can be specified by:
  1861.  
  1862.   color red 1.0 green 0.8 blue 0.8
  1863.  
  1864.  
  1865. The values after each keyword should be in the range from 0.0 to 1.0. Any of
  1866. the three components not specified will default to 0. A shortcut notation may
  1867. also be used. The following produces the same shade of pink:
  1868.  
  1869.   color rgb <1.0, 0.8, 0.8>
  1870.  
  1871.  
  1872. 4.1.6            Defining a Light Source
  1873.  
  1874. One more detail is needed for our scene. We need a light source. Until we
  1875. create one, there is no light in this virtual world. Thus we add the line
  1876.  
  1877.   light_source { <2, 4, -3> color White}
  1878.  
  1879.  
  1880. to the scene file to get our first complete POV-Ray scene file as shown
  1881. below.
  1882.  
  1883.   #include "colors.inc"
  1884.  
  1885.   background { color Cyan }
  1886.  
  1887.   camera {
  1888.     location <0, 2, -3>
  1889.     look_at  <0, 1,  2>
  1890.   }
  1891.  
  1892.   sphere {
  1893.     <0, 1, 2>, 2
  1894.     texture {
  1895.       pigment { color Yellow }
  1896.     }
  1897.   }
  1898.  
  1899.   light_source { <2, 4, -3> color White}
  1900.  
  1901.  
  1902. The vector in the light_source statement specifies the location of the light
  1903. as two units to our right, four units above the origin and three units back
  1904. from the origin. The light source is invisible, it only casts light, so no
  1905. texture is needed.
  1906.  
  1907. That's it! We close the file and render a small picture of it using the
  1908. command
  1909.  
  1910.   povray +w160 +h120 +p +x +d0 -v -idemo.pov
  1911.  
  1912.  
  1913. If our computer does not use the command line, we have to read the platform
  1914. specific docs for the correct command to render the scene.
  1915.  
  1916. We may also set any other command line options we like. The scene is written
  1917. to the image file demo.tga (or some suffix other than .tga if our computer
  1918. uses a different default file format).
  1919.  
  1920. The scene we just traced isn't quite state of the art but we will have to
  1921. start with the basics before we soon get to much more fascinating features
  1922. and scenes.
  1923.  
  1924. 4.2              Using the Camera
  1925.  
  1926.  
  1927. 4.2.1            Using Focal Blur
  1928.  
  1929. Let's construct a simple scene to illustrate the use of focal blur. For this
  1930. example we will use a pink sphere, a green box and a blue cylinder with the
  1931. sphere placed in the foreground, the box in the center and the cylinder in
  1932. the background. A checkered floor for perspective and a couple of light
  1933. sources will complete the scene.
  1934.  
  1935. We create a new file called focaldem.pov and enter the following text
  1936.  
  1937.   #include "colors.inc"
  1938.   #include "shapes.inc"
  1939.   #include "textures.inc"
  1940.  
  1941.   #version 3.0
  1942.  
  1943.   global_settings {
  1944.     assumed_gamma 2.2 // for most PC monitors
  1945.     max_trace_level 5
  1946.   }
  1947.  
  1948.   sphere { <1, 0, -6>, 0.5
  1949.     finish {
  1950.       ambient 0.1
  1951.       diffuse 0.6
  1952.     }
  1953.     pigment { NeonPink }
  1954.   }
  1955.  
  1956.   box { <-1, -1, -1>, < 1,  1,  1>
  1957.     rotate <0, -20, 0>
  1958.     finish {
  1959.       ambient 0.1
  1960.       diffuse 0.6
  1961.     }
  1962.     pigment { Green }
  1963.   }
  1964.  
  1965.   cylinder { <-6, 6, 30>, <-6, -1, 30>, 3
  1966.     finish {
  1967.       ambient 0.1
  1968.       diffuse 0.6
  1969.     }
  1970.     pigment {NeonBlue}
  1971.   }
  1972.  
  1973.   plane { y, -1.0
  1974.     pigment {
  1975.       checker color Gray65 color Gray30
  1976.     }
  1977.   }
  1978.  
  1979.   light_source { <5, 30, -30> color White }
  1980.  
  1981.   light_source { <-5, 30, -30> color White }
  1982.  
  1983.  
  1984. Now we can proceed to place our focal blur camera to an appropriate viewing
  1985. position. Straight back from our three objects will yield a nice view.
  1986. Adjusting the focal point will move the point of focus anywhere in the scene.
  1987. We just add the following lines to the file:
  1988.  
  1989.   camera {
  1990.     location <0.0, 1.0, -10.0>
  1991.     look_at  <0.0, 1.0,  0.0>
  1992.  
  1993.   //  focal_point <-6, 1, 30>    // blue cylinder in focus
  1994.   //  focal_point < 0, 1,  0>    // green box in focus
  1995.     focal_point < 1, 1, -6>    // pink sphere in focus
  1996.  
  1997.     aperture 0.4     // a nice compromise
  1998.   //  aperture 0.05    // almost everything is in focus
  1999.   //  aperture 1.5     // much blurring
  2000.  
  2001.   //  blur_samples 4       // fewer samples, faster to render
  2002.     blur_samples 20      // more samples, higher quality image
  2003.   }
  2004.  
  2005.  
  2006. The focal point is simply the point at which the focus of the camera is at
  2007. its sharpest. We position this point in our scene and assign a value to the
  2008. aperture to adjust how close or how far away we want the focal blur to occur
  2009. from the focused area.
  2010.  
  2011. The aperture setting can be considered an area of focus. Opening up the
  2012. aperture has the effect of making the area of focus smaller while giving the
  2013. aperture a smaller value makes the area of focus larger. This is how we
  2014. control where focal blur begins to occur around the focal point.
  2015.  
  2016. The blur samples setting determines how many rays are used to sample each
  2017. pixel. Basically, the more rays that are used the higher the quality of the
  2018. resultant image, but consequently the longer it takes to render. Each scene
  2019. is different so we have to experiment. This tutorial has examples of 4 and 20
  2020. samples but we can use more for high resolution images. We should not use
  2021. more samples than is necessary to achieve the desired quality - more samples
  2022. take more time to render. The confidence and variance settings are covered in
  2023. section "Focal Blur".
  2024.  
  2025. We experiment with the focal point, aperture, and blur sample settings. The
  2026. scene has lines with other values that we can try by commenting out the
  2027. default line with double slash marks and un-commenting the line we wish to
  2028. try out. We make only one change at a time to see the effect on the scene.
  2029.  
  2030. Two final points when tracing a scene using a focal blur camera. We needn't
  2031. specify anti-aliasing (the \Clo{+A} switch) because the focal blur code uses
  2032. its one sampling method that automatically takes care of anti-aliasing. Focal
  2033. blur can only be used with the perspective camera.
  2034.  
  2035. 4.3              Simple Shapes
  2036.  
  2037. So far we have just used the sphere shape. There are many other types of
  2038. shapes that can be rendered by POV-Ray. The following sections will describe
  2039. how to use some of the more simple objects as a replacement for the sphere
  2040. used above.
  2041.  
  2042. 4.3.1            Box Object
  2043.  
  2044. The box is one of the most common objects used. We try this example in place
  2045. of the sphere:
  2046.  
  2047.   box {
  2048.     <-1, 0,   -1>,  // Near lower left corner
  2049.     < 1, 0.5,  3>   // Far upper right corner
  2050.  
  2051.     texture {
  2052.       T_Stone25     // Pre-defined from stones.inc
  2053.       scale 4       // Scale by the same amount in all
  2054.                     // directions
  2055.     }
  2056.  
  2057.     rotate y*20     // Equivalent to "rotate <0,20,0>"
  2058.   }
  2059.  
  2060.  
  2061. In the example we can see that a box is defined by specifying the 3D
  2062. coordinates of its opposite corners. The first vector must be the minimum x-,
  2063. y- and z-coordinates and the 2nd vector must be the maximum x-, y- and
  2064. z-values. Box objects can only be defined parallel to the axes of the world
  2065. coordinate system. We can later rotate them to any angle. Note that we can
  2066. perform simple math on values and vectors. In the rotate parameter we
  2067. multiplied the vector identifier y by 20. This is the same as <0,1,0>*20 or
  2068. <0,20,0>.
  2069.  
  2070. 4.3.2            Cone Object
  2071.  
  2072. Here's another example showing how to use a cone:
  2073.  
  2074.   cone {
  2075.     <0, 1, 0>, 0.3    // Center and radius of one end
  2076.     <1, 2, 3>, 1.0    // Center and radius of other end
  2077.  
  2078.     texture { T_Stone25 scale 4 }
  2079.   }
  2080.  
  2081.  
  2082. The cone shape is defined by the center and radius of each end. In this
  2083. example one end is at location <0,1,0> and has a radius of 0.3 while the
  2084. other end is centered at <1,2,3> with radius=1. If we want the cone to come
  2085. to a sharp point we must use radius=0. The solid end caps are parallel to
  2086. each other and perpendicular to the cone axis. If we want an open cone with
  2087. no end caps we have to add the keyword open after the 2nd radius like this:
  2088.  
  2089.   cone {
  2090.     <0, 1, 0>, 0.3    // Center and radius of one end
  2091.     <1, 2, 3>, 1.0    // Center and radius of other end
  2092.     open              // Removes end caps
  2093.  
  2094.     texture { T_Stone25 scale 4 }
  2095.   }
  2096.  
  2097.  
  2098. 4.3.3            Cylinder Object
  2099.  
  2100. We may also define a cylinder like this:
  2101.  
  2102.   cylinder {
  2103.     <0, 1, 0>,     // Center of one end
  2104.     <1, 2, 3>,     // Center of other end
  2105.     0.5            // Radius
  2106.     open           // Remove end caps
  2107.  
  2108.     texture { T_Stone25 scale 4 }
  2109.   }
  2110.  
  2111.  
  2112. 4.3.4            Plane Object
  2113.  
  2114. Let's try out a computer graphics standard - The Checkered Floor. We add the
  2115. following object to the first version of the demo.pov file, the one including
  2116. the sphere.
  2117.  
  2118.   plane { <0, 1, 0>, -1
  2119.     pigment {
  2120.       checker color Red, color Blue
  2121.     }
  2122.   }
  2123.  
  2124.  
  2125. The object defined here is an infinite plane. The vector <0,1,0> is the
  2126. surface normal of the plane (i.e. if we were standing on the surface, the
  2127. normal points straight up). The number afterward is the distance that the
  2128. plane is displaced along the normal from the origin - in this case, the floor
  2129. is placed at y=-1 so that the sphere at y=1, radius=2, is resting on it.
  2130.  
  2131. We note that even though there is no texture statement there is an implied
  2132. texture here. We might find that continually typing statements that are
  2133. nested like texture {pigment} can get to be tiresome so POV-Ray let's us
  2134. leave out the texture statement under many circumstances. In general we only
  2135. need the texture block surrounding a texture identifier (like the T_Stone25
  2136. example above), or when creating layered textures (which are covered later).
  2137.  
  2138. This pigment uses the checker color pattern and specifies that the two colors
  2139. red and blue should be used.
  2140.  
  2141. Because the vectors <1,0,0>, <0,1,0> and <0,0,1> are used frequently, POV-Ray
  2142. has three built-in vector identifiers x, y and z respectively that can be
  2143. used as a shorthand. Thus the plane could be defined as:
  2144.  
  2145.   plane { y, -1
  2146.     pigment { ... }
  2147.   }
  2148.  
  2149.  
  2150. Note that we do not use angle brackets around vector identifiers.
  2151.  
  2152. Looking at the floor, we notice that the ball casts a shadow on the floor.
  2153. Shadows are calculated very accurately by the ray-tracer, which creates
  2154. precise, sharp shadows. In the real world, penumbral or "soft" shadows are
  2155. often seen. Later we will learn how to use extended light sources to soften
  2156. the shadows.
  2157.  
  2158. 4.3.5            Standard Include Objects
  2159.  
  2160. The standard include file shapes.inc contains some pre-defined shapes that
  2161. are about the size of a sphere with a radius of one unit. We can invoke them
  2162. like this:
  2163.  
  2164.   #include "shapes.inc"
  2165.  
  2166.   object {
  2167.     UnitBox
  2168.     texture { T_Stone25 scale 4 }
  2169.     scale 0.75
  2170.     rotate <-20,25,0>
  2171.     translate y
  2172.   }
  2173.  
  2174.  
  2175. 4.4              Advanced Shapes
  2176.  
  2177. After we have gained some experience with the simpler shapes available in
  2178. POV-Ray it is time to go on to the more advanced, thrilling shapes.
  2179.  
  2180. We should be aware that the shapes described below are not trivial to
  2181. understand. We needn't be worried though if we do not know how to use them or
  2182. how they work. We just try the examples and play with the features described
  2183. in the reference chapter. There is nothing better than learning by doing.
  2184.  
  2185. 4.4.1            Bicubic Patch Object
  2186.  
  2187. Bicubic or Bezier patches are useful surface representations because they
  2188. allow an easy definition of surfaces using only a few control points. The
  2189. control points serve to determine the shape of the patch. Instead of defining
  2190. the vertices of triangles, we simply give the coordinates of the control
  2191. points. A single patch has 16 control points, four at each corner, and the
  2192. rest positioned to divide the patch into smaller sections. For ray-tracing
  2193. (or rendering) the patches are approximated using triangles. Bezier patches
  2194. are almost always created using a third party modeller so for this tutorial,
  2195. we will use moray (any other modeller that supports Bezier patches and
  2196. POV-Ray can also be used). We will use moray only to create the patch itself,
  2197. not the other elements of the scene.
  2198.  
  2199. Bezier patches are actually very useful and, with a little practice, some
  2200. pretty amazing things can be created with them. For our first tutorial, let's
  2201. make a sort of a teepee/tent shape using a single sheet patch.
  2202.  
  2203. First, we start moray and, from the main edit screen, we click on "CREATE".
  2204. We Name our object Teepee. The "CREATE BEZIER PATCH" dialogue box will
  2205. appear. We have to make sure that "SHEET" is depressed. We click on "OK,
  2206. CREATE". At the bottom of the main edit screen, we click on "EXTENDED EDIT".
  2207.  
  2208. We hold the cursor over the "TOP" view and right click to make the pop-up
  2209. menu appear. We click on "MAXIMIZE". We [ALT]-drag to zoom in a little. We
  2210. click on "MARK ALL", and under the transformation mode box, "UFRM SCL". We
  2211. drag the mouse to scale the patch until it is approximately four units wide.
  2212. We click on "TRANSLATE", and move the patch so that its center is over the
  2213. origin. We right click "MINIMIZE" and "UNMARK ALL".
  2214.  
  2215. We [SHIFT]-drag a box around the lower right control point to mark it. We
  2216. [ALT]-zoom into the "FRONT" view so that we can see the patch better. In the
  2217. "FRONT" view, we "TRANSLATE" that point 10 units along the negative z-axis
  2218. (we note that in MORAY z is up). We "UNMARK ALL". We repeat this procedure
  2219. for each of the other three corner points. We make sure we remember to
  2220. "UNMARK ALL" once each point has been translated. We should have a shape that
  2221. looks as though it is standing on four pointed legs. We "UNMARK ALL".
  2222.  
  2223. Working once again in the "TOP" view, we [SHIFT]-drag a box around the four
  2224. center control points to mark them. We right-click over the "TOP" view and
  2225. "MAXIMIZE". We click on "UFRM SCL" and drag the mouse to scale the four
  2226. points close together. We [ALT]-drag to zoom closer and get them as close
  2227. together as we can. We [ALT]-drag to zoom out, right click and "MINIMIZE".
  2228.  
  2229. In the "FRONT" view, we "TRANSLATE" the marked points 10 units along the
  2230. positive z-axis. We "UNMARK ALL". The resulting shape is quite interesting,
  2231. was simple to model, and could not be produced using CSG primitives. Now
  2232. let's use it in a scene.
  2233.  
  2234. We click on "DONE" to return to the main edit screen. We note that U_STEPS
  2235. and V_STEPS are both set to 3 and flatness is set to 0.01. We leave them
  2236. alone for now. We click on "FILES" and then "SAVE SEL" (save selection). We
  2237. name our new file teepee1.mdl. We press [F3] and open teepee1.mdl. There is
  2238. no need to save the original file. When teepee1 is open, we create a quick
  2239. "dummy" texture (moray will not allow us to export data without a texture).
  2240. We use white with default finish and name it TeePeeTex. We apply it to the
  2241. object, save the file and press [CTRL-F9]. moray will create two files:
  2242. teepee1.inc and teepee1.pov.
  2243.  
  2244. We exit moray and copy teepee1.inc and teepee1.pov into our working directory
  2245. where we are doing these tutorials. We create a new file called bezdemo.pov
  2246. and edit it as follows:
  2247.  
  2248.   #include "colors.inc"
  2249.  
  2250.   camera {
  2251.     location <0, .1, -60>
  2252.     look_at 0
  2253.     angle 40
  2254.   }
  2255.  
  2256.   background { color Gray25 }  //to make the patch easier to see
  2257.  
  2258.   light_source { <300, 300, -700> White }
  2259.  
  2260.   plane { y, -12
  2261.     texture {
  2262.       pigment {
  2263.         checker
  2264.         color Green
  2265.         color Yellow
  2266.       }
  2267.     }
  2268.   }
  2269.  
  2270.  
  2271. Using a text editor, we create and declare a simple texture for our teepee
  2272. object:
  2273.  
  2274.   #declare TeePeeTex = texture {
  2275.     pigment {
  2276.       color rgb <1, 1, 1,>
  2277.     }
  2278.     finish {
  2279.       ambient .2
  2280.       diffuse .6
  2281.     }
  2282.   }
  2283.  
  2284.  
  2285. We paste in the bezier patch data from teepee1.pov (the additional object
  2286. keywords added by moray were removed):
  2287.  
  2288.   bicubic_patch {
  2289.     type 1 flatness 0.0100 u_steps 3 v_steps 3,
  2290.     <-5.174134, 5.528420, -13.211995>,
  2291.     <-1.769023, 5.528420, 0.000000>,
  2292.     <1.636088, 5.528420, 0.000000>,
  2293.     <5.041199, 5.528420, -13.003932>,
  2294.     <-5.174134, 1.862827, 0.000000>,
  2295.     <0.038471, 0.031270, 18.101474>,
  2296.     <0.036657, 0.031270, 18.101474>,
  2297.     <5.041199, 1.862827, 0.000000>,
  2298.     <-5.174134, -1.802766, 0.000000>,
  2299.     <0.038471, 0.028792, 18.101474>,
  2300.     <0.036657, 0.028792, 18.101474>,
  2301.     <5.041199, -1.802766, 0.000000>,
  2302.     <-5.174134, -5.468359, -13.070366>,
  2303.     <-1.769023, -5.468359, 0.000000>,
  2304.     <1.636088, -5.468359, 0.000000>,
  2305.     <4.974128, -5.468359, -12.801446>
  2306.     texture {
  2307.       TeePeeTex
  2308.     }
  2309.     rotate -90*x  // to orient the object to LHC
  2310.     rotate 25*y   // to see the four "legs" better
  2311.   }
  2312.  
  2313.  
  2314.  
  2315. We add the above rotations so that the patch is oriented to POV-Ray's
  2316. left-handed coordinate system (remember the patch was made in moray in a
  2317. right handed coordinate system), so we can see all four legs. Rendering this
  2318. at 200x150 -a we see pretty much what we expect, a white teepee over a green
  2319. and yellow checkered plane. Let's take a little closer look. We render it
  2320. again, this time at 320x200.
  2321.  
  2322. Now we see that something is amiss. There appears to be sharp angling, almost
  2323. like faceting, especially near the top. This is indeed a kind of faceting and
  2324. is due to the U_STEPS and V_STEPS parameters. Let's change these from 3 to 4
  2325. and see what happens.
  2326.  
  2327. That's much better, but it took a little longer to render. This is an
  2328. unavoidable tradeoff. If we want even finer detail, we must use a U_STEPS and
  2329. V_STEPS value of 5 and set flatness to 0. But we must expect to use lots of
  2330. memory and an even longer tracing time.
  2331.  
  2332. Well, we can't just leave this scene without adding a few items just for
  2333. interest. We declare the patch object and scatter a few of them around the
  2334. scene:
  2335.  
  2336.   #declare TeePee = bicubic_patch {
  2337.     type 1 flatness 0.0100 u_steps 3 v_steps 3,
  2338.     <-5.174134, 5.528420, -13.211995>,
  2339.     <-1.769023, 5.528420, 0.000000>,
  2340.     <1.636088, 5.528420, 0.000000>,
  2341.     <5.041199, 5.528420, -13.003932>,
  2342.     <-5.174134, 1.862827, 0.000000>,
  2343.     <0.038471, 0.031270, 18.101474>,
  2344.     <0.036657, 0.031270, 18.101474>,
  2345.     <5.041199, 1.862827, 0.000000>,
  2346.     <-5.174134, -1.802766, 0.000000>,
  2347.     <0.038471, 0.028792, 18.101474>,
  2348.     <0.036657, 0.028792, 18.101474>,
  2349.     <5.041199, -1.802766, 0.000000>,
  2350.     <-5.174134, -5.468359, -13.070366>,
  2351.     <-1.769023, -5.468359, 0.000000>,
  2352.     <1.636088, -5.468359, 0.000000>,
  2353.     <4.974128, -5.468359, -12.801446>
  2354.     texture {
  2355.       TeePeeTex
  2356.      }
  2357.      rotate -90*x // to orient the object to LHC
  2358.      rotate 25*y  // to see the four "legs" better
  2359.   }
  2360.  
  2361.   object { TeePee }
  2362.  
  2363.   object { TeePee translate <8, 0, 8> }
  2364.  
  2365.   object { TeePee translate <-9, 0, 9> }
  2366.  
  2367.   object { TeePee translate <18, 0, 24> }
  2368.  
  2369.   object { TeePee translate <-18, 0, 24> }
  2370.  
  2371.  
  2372. That looks good. Let's do something about that boring gray background. We
  2373. delete the background declaration and replace it with:
  2374.  
  2375.   plane { y, 500
  2376.     texture {
  2377.       pigment { SkyBlue }
  2378.       finish { ambient 1 diffuse 0}
  2379.      }
  2380.      texture {
  2381.        pigment {
  2382.          bozo
  2383.          turbulence .5
  2384.          color_map {
  2385.            [0 White]
  2386.            [1 White filter 1]
  2387.          }
  2388.        }
  2389.        finish { ambient 1 diffuse 0 }
  2390.        scale <1000, 250, 250>
  2391.        rotate <5, 45, 0>
  2392.     }
  2393.   }
  2394.  
  2395.  
  2396. This adds a pleasing cirrus-cloud filled sky. Now, let's change the checkered
  2397. plane to rippled sand dunes:
  2398.  
  2399.   plane {y,-12
  2400.     texture {
  2401.       pigment {
  2402.         color <.85, .5, .15>
  2403.       }
  2404.       finish {
  2405.         ambient .25
  2406.         diffuse .6
  2407.         crand .5
  2408.       }
  2409.       normal {
  2410.         ripples .35
  2411.         turbulence .25
  2412.         frequency 5
  2413.       }
  2414.       scale 10
  2415.       translate 50*x
  2416.     }
  2417.   }
  2418.  
  2419.  
  2420. We render this at 320x240 -a. Not bad! Let's just add one more element. Let's
  2421. place a golden egg under each of the teepees. And since this is a bezier
  2422. patch tutorial, let's make the eggs out of bezier patches.
  2423.  
  2424. We return to moray and create another bezier patch. We name it Egg1 and
  2425. select "CYLINDRICAL 2 - PATCH" from the "CREATE BEZIER PATCH" dialogue box.
  2426. We click on "EXTENDED EDIT". We "MARK ALL" and rotate the patch so that the
  2427. cylinder lays on its side. We "UNMARK ALL". In the "FRONT" view, we
  2428. [SHIFT]-drag a box around the four points on the right end to mark them. In
  2429. the "SIDE" view, we right click and "MAXIMIZE". We [ALT]-drag to zoom in a
  2430. little closer. We "UFRM SCL" the points together as close as possible. We
  2431. zoom in closer to get them nice and tight. We zoom out, right click and
  2432. "MINIMIZE".
  2433.  
  2434. We click on "TRANSLATE" and drag the points to the left so that they are
  2435. aligned on the z-axis with the next group of four points. This should create
  2436. a blunt end to the patch. We repeat this procedure for the other end. We
  2437. "UNMARK ALL".
  2438.  
  2439. In the "FRONT" view, the control grid should be a rectangle now and the patch
  2440. should
  2441. be an ellipsoid. We [SHIFT]-drag a box around the upper right corner of the
  2442. control grid to mark those points. We then [SHIFT]-drag a box around the
  2443. lower right corner to mark those points as well. In the "SIDE" view, we "UFRM
  2444. SCL" the points apart a little to make that end of the egg a little wider
  2445. than the other. We "UNMARK ALL".
  2446.  
  2447. The egg may need a little proportional adjustment. We should be able to "MARK
  2448. ALL" and "LOCAL SCL" in the three views until we get it to look like an egg.
  2449. When we are satisfied that it does, we "UNMARK ALL" and click on done.
  2450. Learning from our teepee object, we now go ahead and change U_STEPS and
  2451. V_STEPS to 4.
  2452.  
  2453. We create a dummy texture, white with default finish, name it EggTex and
  2454. apply it to the egg. From the FILES menu, we "SAVE SEL" to filename egg1.mdl.
  2455. We load this file and export ([CTRL F9]). We exit moray and copy the files
  2456. egg1.inc and egg1.pov into our working directory.
  2457.  
  2458. Back in bezdemo.pov, we create a nice, shiny gold texture:
  2459.  
  2460.   #declare EggTex = texture {
  2461.     pigment { BrightGold }
  2462.     finish {
  2463.       ambient .1
  2464.       diffuse .4
  2465.       specular 1
  2466.       roughness 0.001
  2467.       reflection .5
  2468.       metallic
  2469.     }
  2470.   }
  2471.  
  2472.  
  2473. And while we're at it, let's dandy up our TeePeeTex texture:
  2474.  
  2475.   #declare TeePeeTex = texture {
  2476.     pigment { Silver }
  2477.     finish {
  2478.       ambient .1
  2479.       diffuse .4
  2480.       specular 1
  2481.       roughness 0.001
  2482.       reflection .5
  2483.       metallic
  2484.     }
  2485.   }
  2486.  
  2487.  
  2488. Now we paste in our egg patch data and declare our egg:
  2489.  
  2490.   #declare Egg = union { // Egg1
  2491.     bicubic_patch {
  2492.       type 1 flatness 0.0100 u_steps 4 v_steps 4,
  2493.       <2.023314, 0.000000, 4.355987>,
  2494.       <2.023314, -0.000726, 4.355987>,
  2495.       <2.023312, -0.000726, 4.356867>,
  2496.       <2.023312, 0.000000, 4.356867>,
  2497.       <2.032037, 0.000000, 2.734598>,
  2498.       <2.032037, -1.758562, 2.734598>,
  2499.       <2.027431, -1.758562, 6.141971>,
  2500.       <2.027431, 0.000000, 6.141971>,
  2501.       <-1.045672, 0.000000, 3.281572>,
  2502.       <-1.045672, -1.758562, 3.281572>,
  2503.       <-1.050279, -1.758562, 5.414183>,
  2504.       <-1.050279, 0.000000, 5.414183>,
  2505.       <-1.044333, 0.000000, 4.341816>,
  2506.       <-1.044333, -0.002947, 4.341816>,
  2507.       <-1.044341, -0.002947, 4.345389>,
  2508.       <-1.044341, 0.000000, 4.345389>
  2509.     }
  2510.     bicubic_patch {
  2511.       type 1 flatness 0.0100 u_steps 4 v_steps 4,
  2512.       <2.023312, 0.000000, 4.356867>,
  2513.       <2.023312, 0.000726, 4.356867>,
  2514.       <2.023314, 0.000726, 4.355987>,
  2515.       <2.023314, 0.000000, 4.355987>,
  2516.       <2.027431, 0.000000, 6.141971>,
  2517.       <2.027431, 1.758562, 6.141971>,
  2518.       <2.032037, 1.758562, 2.734598>,
  2519.       <2.032037, 0.000000, 2.734598>,
  2520.       <-1.050279, 0.000000, 5.414183>,
  2521.       <-1.050279, 1.758562, 5.414183>,
  2522.       <-1.045672, 1.758562, 3.281572>,
  2523.       <-1.045672, 0.000000, 3.281572>,
  2524.       <-1.044341, 0.000000, 4.345389>,
  2525.       <-1.044341, 0.002947, 4.345389>,
  2526.       <-1.044333, 0.002947, 4.341816>,
  2527.       <-1.044333, 0.000000, 4.341816>
  2528.     }
  2529.     texture { EggTex }
  2530.     translate <0.5, 0, -5>  // centers the egg around the origin
  2531.     translate -9.8*y        // places the egg on the ground
  2532.   }
  2533.  
  2534.  
  2535. We now place a copy of the egg under each teepee. This should require only
  2536. the x- and z-coordinates of each teepee to be changed:
  2537.  
  2538.   object { Egg }
  2539.  
  2540.   object { Egg translate <8, 0, 8> }
  2541.  
  2542.   object { Egg translate <-9, 0, 9> }
  2543.  
  2544.   object { Egg translate <18, 0, 24> }
  2545.  
  2546.   object { Egg translate <-18, 0, 24> }
  2547.  
  2548.  
  2549. Scene build with different Bezier patches.
  2550.  
  2551. We render this at 320x240 -A. Everything looks good so we run it again at
  2552. 640x480 +A. Now we see that there is still some faceting near the top of the
  2553. teepees and on the eggs as well. The only solution is to raise U_STEPS and
  2554. V_STEPS from 4 to 5 and set flatness to 0 for all our bezier objects. We make
  2555. the changes and render it again at 640x480 +A.
  2556.  
  2557. 4.4.2            Blob Object
  2558.  
  2559. Blobs are described as spheres and cylinders covered with "goo" which
  2560. stretches to smoothly join them (see section "Blob"). Ideal for modelling
  2561. atoms and molecules, blobs are also powerful tools for creating many smooth
  2562. flowing "organic" shapes.
  2563.  
  2564. A slightly more mathematical way of describing a blob would be to say that it
  2565. is one object made up of two or more component pieces. Each piece is really
  2566. an invisible field of force which starts out at a particular strength and
  2567. falls off smoothly to zero at a given radius. Where ever these components
  2568. overlap in space, their field strength gets added together (and yes, we can
  2569. have negative strength which gets subtracted out of the total as well). We
  2570. could have just one component in a blob, but except for seeing what it looks
  2571. like there is little point, since the real beauty of blobs is the way the
  2572. components interact with one another.
  2573.  
  2574. Let us take a simple example blob to start. Now, in fact there are a couple
  2575. different types of components but we will look at them a little later. For
  2576. the sake of a simple first example, let us just talk about spherical
  2577. components. Here is a sample POV-Ray code showing a basic camera, light, and
  2578. a simple two component blob (this scene is called blobdem1.pov):
  2579.  
  2580.   #include "colors.inc"
  2581.  
  2582.   camera {
  2583.     angle 15
  2584.     location <0,2,-10>
  2585.     look_at <0,0,0>
  2586.   }
  2587.  
  2588.   light_source { <10, 20, -10> color White }
  2589.  
  2590.   blob {
  2591.     threshold .65
  2592.     sphere { <.5,0,0>, .8, 1 pigment {Blue} }
  2593.     sphere { <-.5,0,0>,.8, 1 pigment {Pink} }
  2594.  
  2595.     finish { phong 1 }
  2596.   }
  2597.  
  2598.  
  2599. A simple, two-part blob.
  2600.  
  2601. The threshold is simply the overall strength value at which the blob becomes
  2602. visible. Any points within the blob where the strength matches the threshold
  2603. exactly form the surface of the blob shape. Those less than the threshold are
  2604. outside and those greater than are inside the blob.
  2605.  
  2606. We note that the spherical component looks a lot like a simple sphere object.
  2607. We have the sphere keyword, the vector representing the location of the
  2608. center of the sphere and the float representing the radius of the sphere. But
  2609. what is that last float value? That is the individual strength of that
  2610. component. In a spherical component, that is how strong the component's field
  2611. is at the center of the sphere. It will fall off in a linear progression
  2612. until it reaches exactly zero at the radius of the sphere.
  2613.  
  2614. Before we render this test image, we note that we have given each component a
  2615. different pigment. POV-Ray allows blob components to be given separate
  2616. textures. We have done this here to make it clearer which parts of the blob
  2617. are which. We can also texture the whole blob as one, like the finish
  2618. statement at the end, which applies to all components since it appears at the
  2619. end, outside of all the components. We render the scene and get a basic
  2620. kissing spheres type blob.
  2621.  
  2622. The image we see shows the spheres on either side, but they are smoothly
  2623. joined by that bridge section in the center. This bridge represents where the
  2624. two fields overlap, and therefore stay above the threshold for longer than
  2625. elsewhere in the blob. If that is not totally clear, we add the following two
  2626. objects to our scene and re-render (see file blobdem2.pov). We note that
  2627. these are meant to be entered as separate sphere objects, not more components
  2628. in the blob.
  2629.  
  2630.   sphere { <.5,0,0>, .8
  2631.     pigment { Yellow transmit .75 }
  2632.   }
  2633.  
  2634.   sphere { <-.5,0,0>, .8
  2635.     pigment { Green transmit .75 }
  2636.   }
  2637.  
  2638.  
  2639. The spherical components made visible.
  2640.  
  2641. Now the secrets of the kissing spheres are laid bare. These semi-transparent
  2642. spheres show where the components of the blob actually are. If we have not
  2643. worked with blobs before, we might be surprised to see that the spheres we
  2644. just added extend way farther out than the spheres that actually show up on
  2645. the blobs. That of course is because our spheres have been assigned a
  2646. starting strength of one, which gradually fades to zero as we move away from
  2647. the sphere's center. When the strength drops below the threshold (in this
  2648. case 0.65) the rest of the sphere becomes part of the outside of the blob and
  2649. therefore is not visible.
  2650.  
  2651. See the part where the two transparent spheres overlap? We note that it
  2652. exactly corresponds to the bridge between the two spheres. That is the region
  2653. where the two components are both contributing to the overall strength of the
  2654. blob at that point. That is why the bridge appears: that region has a high
  2655. enough strength to stay over the threshold, due to the fact that the combined
  2656. strength of two spherical components is overlapping there.
  2657.  
  2658. 4.4.2.1          Component Types and Other New Features
  2659.  
  2660. The shape shown so far is interesting, but limited. POV-Ray has a few extra
  2661. tricks that extend its range of usefulness however. For example, as we have
  2662. seen, we can assign individual textures to blob components, we can also apply
  2663. individual transformations (translate, rotate and scale) to stretch, twist,
  2664. and squash pieces of the blob as we require. And perhaps most interestingly,
  2665. the blob code has been extended to allow cylindrical components.
  2666.  
  2667. Before we move on to cylinders, it should perhaps be mentioned that the old
  2668. style of components used in previous versions of POV-Ray still work. Back
  2669. then, all components were spheres, so it was not necessary to say sphere or
  2670. cylinder. An old style component had the form:
  2671.  
  2672.   component STRENGTH, RADIUS, <CENTER>
  2673.  
  2674.  
  2675. This has the same effect as a spherical component, just as we already saw
  2676. above. This is only useful for backwards compatibility. If we already have
  2677. POV-Ray files with blobs from earlier versions, this is when we would need to
  2678. recognize these components. We note that the old style components did not put
  2679. braces around the strength, radius and center, and of course, we cannot
  2680. independantly transform or texture them, so if we are modifying an older work
  2681. into a new version, it may arguably be of benefit to convert old style
  2682. components into spherical components anyway.
  2683.  
  2684. Now for something new and different: cylindrical components. It could be
  2685. argued that all we ever needed to do to make a roughly cylindrical portion of
  2686. a blob was string a line of spherical components together along a straight
  2687. line. Which is fine, if we like having extra to type, and also assuming that
  2688. the cylinder was oriented along an axis. If not, we would have to work out
  2689. the mathematical position of each component to keep it is a straight line.
  2690. But no more! Cylindrical components have arrived.
  2691.  
  2692. We replace the blob in our last example with the following and re-render. We
  2693. can get rid of the transparent spheres too, by the way.
  2694.  
  2695.   blob {
  2696.     threshold .65
  2697.  
  2698.     cylinder { <-.75,-.75,0>, <.75,.75,0>, .5, 1 }
  2699.  
  2700.     pigment { Blue }
  2701.     finish { phong 1 }
  2702.   }
  2703.  
  2704.  
  2705. We only have one component so that we can see the basic shape of the
  2706. cylindrical component. It is not quite a true cylinder - more of a sausage
  2707. shape, being a cylinder capped by two hemi-spheres. We think of it as if it
  2708. were an array of spherical components all closely strung along a straight
  2709. line.
  2710.  
  2711. As for the component declaration itself: simple, logical, exactly as we would
  2712. expect it to look (assuming we have been awake so far): it looks pretty much
  2713. like the declaration of a cylinder object, with vectors specifying the two
  2714. endpoints and a float giving the radius of the cylinder. The last float, of
  2715. course, is the strength of the component. Just as with spherical components,
  2716. the strength will determine the nature and degree of this component's
  2717. interaction with its fellow components. In fact, next let us give this fellow
  2718. something to interact with, shall we?
  2719.  
  2720. 4.4.2.2          Complex Blob Constructs and Negative Strength
  2721.  
  2722. Beginning a new POV-Ray file called blobdem3.pov, we enter this somewhat more
  2723. complex example:
  2724.  
  2725.   #include "colors.inc"
  2726.  
  2727.   camera {
  2728.     angle 20
  2729.     location<0,2,-10>
  2730.     look_at<0,0,0>
  2731.   }
  2732.  
  2733.   light_source { <10, 20, -10> color White }
  2734.  
  2735.   blob {
  2736.     threshold .65
  2737.  
  2738.     sphere { <-.23,-.32,0>,.43, 1 scale <1.95,1.05,.8> }   //palm
  2739.     sphere { <+.12,-.41,0>,.43, 1 scale <1.95,1.075,.8> }  //palm
  2740.     sphere { <-.23,-.63,0>, .45, .75 scale <1.78, 1.3,1> } //midhand
  2741.     sphere { <+.19,-.63,0>, .45, .75 scale <1.78, 1.3,1> } //midhand
  2742.     sphere { <-.22,-.73,0>, .45, .85 scale <1.4, 1.25,1> } //heel
  2743.     sphere { <+.19,-.73,0>, .45, .85 scale <1.4, 1.25,1> } //heel
  2744.  
  2745.     cylinder { <-.65,-.28,0>, <-.65,.28,-.05>, .26, 1 }    //lower pinky
  2746.     cylinder { <-.65,.28,-.05>, <-.65, .68,-.2>, .26, 1 }  //upper pinky
  2747.  
  2748.     cylinder { <-.3,-.28,0>, <-.3,.44,-.05>, .26, 1 }      //lower ring
  2749.     cylinder { <-.3,.44,-.05>, <-.3, .9,-.2>, .26, 1 }     //upper ring
  2750.  
  2751.     cylinder { <.05,-.28,0>, <.05, .49,-.05>, .26, 1 }     //lower middle
  2752.     cylinder { <.05,.49,-.05>, <.05, .95,-.2>, .26, 1 }    //upper middle
  2753.  
  2754.     cylinder { <.4,-.4,0>, <.4, .512, -.05>, .26, 1 }      //lower index
  2755.     cylinder { <.4,.512,-.05>, <.4, .85, -.2>, .26, 1 }    //upper index
  2756.  
  2757.     cylinder { <.41, -.95,0>, <.85, -.68, -.05>, .25, 1 }  //lower thumb
  2758.     cylinder { <.85,-.68,-.05>, <1.2, -.4, -.2>, .25, 1 }  //upper thumb
  2759.  
  2760.     pigment { Flesh }
  2761.   }
  2762.  
  2763.  
  2764. A hand made with blobs.
  2765.  
  2766. As we can guess from the comments, we are building a hand here. After we
  2767. render this image, we can see there are a few problems with it. The palm and
  2768. heel of the hand would look more realistic if we used a couple dozen smaller
  2769. components rather than the half dozen larger ones we have used, and each
  2770. finger should have three segments instead of two, but for the sake of a
  2771. simplified demonstration, we can overlook these points. But there is one
  2772. thing we really need to address here: This poor fellow appears to have
  2773. horrible painful swelling of the joints!
  2774.  
  2775. A review of what we know of blobs will quickly reveal what went wrong. The
  2776. joints are places where the blob components overlap, therefore the combined
  2777. strength of both components at that point causes the surface to extend
  2778. further out, since it stays over the threshold longer. To fix this, what we
  2779. need are components corresponding to the overlap region which have a negative
  2780. strength to counteract part of the combined field strength. We add the
  2781. following components to our blob (see file blobdem4.pov).
  2782.  
  2783.   sphere { <-.65,.28,-.05>, .26, -1 } //counteract pinky knuckle bulge
  2784.   sphere { <-.65,-.28,0>, .26, -1 }   //counteract pinky palm bulge
  2785.  
  2786.   sphere { <-.3,.44,-.05>, .26, -1 }  //counteract ring knuckle bulge
  2787.   sphere { <-.3,-.28,0>, .26, -1 }    //counteract ring palm bulge
  2788.  
  2789.   sphere { <.05,.49,-.05>, .26, -1 }  //counteract middle knuckle bulge
  2790.   sphere { <.05,-.28,0>, .26, -1 }    //counteract middle palm bulge
  2791.  
  2792.   sphere { <.4,.512,-.05>, .26, -1 }  //counteract index knuckle bulge
  2793.   sphere { <.4,-.4,0>, .26, -1 }      //counteract index palm bulge
  2794.  
  2795.   sphere { <.85,-.68,-.05>, .25, -1 } //counteract thumb knuckle bulge
  2796.   sphere { <.41,-.7,0>, .25, -.89 }   //counteract thumb heel bulge
  2797.  
  2798.  
  2799. The hand without the swolen joints.
  2800.  
  2801. Much better! The negative strength of the spherical components counteracts
  2802. approximately half of the field strength at the points where to components
  2803. overlap, so the ugly, unrealistic (and painful looking) bulging is cut out
  2804. making our hand considerably improved. While we could probably make a yet
  2805. more realistic hand with a couple dozen additional components, what we get
  2806. this time is a considerable improvement. Any by now, we have enough basic
  2807. knowledge of blob mechanics to make a wide array of smooth, flowing organic
  2808. shapes!
  2809.  
  2810. 4.4.3            Height Field Object
  2811.  
  2812. A height field is an object that has a surface that is determined by the
  2813. color value or palette index number of an image designed for that purpose.
  2814. With height fields, realistic mountains and other types of terrain can easily
  2815. be made. First, we need an image from which to create the height field. It
  2816. just so happens that POV-Ray is ideal for creating such an image.
  2817.  
  2818. We make a new file called image.pov and edit it to contain the following:
  2819.  
  2820.   #include "colors.inc"
  2821.  
  2822.   global_settings {
  2823.     assumed_gamma 2.2
  2824.     hf_gray_16
  2825.   }
  2826.  
  2827.  
  2828. The hf_gray_16 keyword causes the output to be in a special 16 bit grayscale
  2829. that is perfect for generating height fields. The normal 8 bit output will
  2830. lead to less smooth surfaces.
  2831.  
  2832. Now we create a camera positioned so that it points directly down the z-axis
  2833. at the origin.
  2834.  
  2835.   camera {
  2836.     location <0, 0, -10>
  2837.     look_at 0
  2838.   }
  2839.  
  2840.  
  2841. We then create a plane positioned like a wall at z=0. This plane will
  2842. completely fill the screen. It will be colored with white and gray wrinkles.
  2843.  
  2844.   plane { z, 10
  2845.     pigment {
  2846.       wrinkles
  2847.       color_map {
  2848.        [0 0.3*White]
  2849.        [1 White]
  2850.       }
  2851.     }
  2852.   }
  2853.  
  2854.  
  2855. Finally, create a light source.
  2856.  
  2857.   light_source { <0, 20, -100> color White }
  2858.  
  2859.  
  2860. We render this scene at 640x480 +A0.1 +FT. We will get an image that will
  2861. produce an excellent height field. We create a new file called hfdemo.pov and
  2862. edit it as follows:
  2863.  
  2864.   #include "colors.inc"
  2865.  
  2866.  
  2867. We add a camera that is two units above the origin and ten units back ...
  2868.  
  2869.   camera{
  2870.     location <0, 2, -10>
  2871.     look_at 0
  2872.     angle 30
  2873.   }
  2874.  
  2875.  
  2876. ... and a light source.
  2877.  
  2878.   light_source{ <1000,1000,-1000> White }
  2879.  
  2880.  
  2881. Now we add the height field. In the following syntax, a Targa image file is
  2882. specified, the height field is smoothed, it is given a simple white pigment,
  2883. it is translated to center it around the origin and it is scaled so that it
  2884. resembles mountains and fills the screen.
  2885.  
  2886.   height_field {
  2887.     tga "image.tga"
  2888.     smooth
  2889.     pigment { White }
  2890.     translate <-.5, -.5, -.5>
  2891.     scale <17, 1.75, 17>
  2892.   }
  2893.  
  2894.  
  2895. We save the file and render it at 320x240 -A. Later, when we are satisfied
  2896. that the height field is the way we want it, we render it at a higher
  2897. resolution with anti-aliasing.
  2898.  
  2899. A height field created completely with POV-Ray.
  2900.  
  2901.  
  2902. 4.4.4            Lathe Object
  2903.  
  2904. In the real world, lathe refers to a process of making patterned rounded
  2905. shapes by spinning the source material in place and carving pieces out as it
  2906. turns. The results can be elaborate, smoothly rounded, elegant looking
  2907. artifacts such as table legs, pottery, etc. In POV-Ray, a lathe object is
  2908. used for creating much the same kind of items, although we are refering to
  2909. the object itself rather than the means of production.
  2910.  
  2911. Here is some source for a really basic lathe (called lathdem1.pov).
  2912.  
  2913.   #include "colors.inc"
  2914.  
  2915.   camera {
  2916.     angle 10
  2917.     location <1, 9, -50>
  2918.     look_at <0, 2, 0>
  2919.   }
  2920.  
  2921.   light_source {
  2922.     <20, 20, -20> color White
  2923.   }
  2924.  
  2925.   lathe {
  2926.     linear_spline
  2927.     6,
  2928.     <0,0>, <1,1>, <3,2>, <2,3>, <2,4>, <0,4>
  2929.     pigment { Blue }
  2930.     finish {
  2931.       ambient .3
  2932.       phong .75
  2933.     }
  2934.   }
  2935.  
  2936.  
  2937. A simple lathe object.
  2938.  
  2939. We render this, and what we see is a fairly simply type of lathe, which looks
  2940. like a child's top. Let's take a look at how this code produced the effect.
  2941.  
  2942. First, a set of six points are declared which the raytracer connects with
  2943. lines. We note that there are only two components in the vectors which
  2944. describe these points. The lines that are drawn are assumed to be in the
  2945. x-y-plane, therefore it is as if all the z-components were assumed to be
  2946. zero. The use of a two-dimensional vector is mandatory (Attempting to use a
  2947. 3D vector would trigger an error... with one exception, which we will explore
  2948. later in the discussion of splines).
  2949.  
  2950. Once the lines are determined, the ray-tracer rotates this line around the
  2951. y-axis, and we can imagine a trail being left through space as it goes, with
  2952. the surface of that trail being the surface of our object.
  2953.  
  2954. The specified points are connected with straight lines because we used the
  2955. linear_spline keyword. There are other types of splines available with the
  2956. lathe, which will result in smooth curving lines, and even rounded curving
  2957. points of transition, but we will get back to that in a moment.
  2958.  
  2959. First, we would like to digress a moment to talk about the difference between
  2960. a lathe and a surface of revolution object (SOR). The SOR object, described
  2961. in a separate tutorial, may seem terribly similar to the lathe at first
  2962. glance. It too declares a series of points and connects them with curving
  2963. lines and then rotates them around the y-axis. The lathe has certain
  2964. advantages, such as different kinds of splines, linear, quadratic and cubic,
  2965. and one more thing:
  2966.  
  2967. The simpler mathematics used by a SOR doesn't allow the curve to double back
  2968. over the same y-coordinates, thus, if using a SOR, any sudden twist which
  2969. cuts back down over the same heights that the curve previously covered will
  2970. trigger an error. For example, suppose we wanted a lathe to arc up from <0,0>
  2971. to <2,2>, then to dip back down to <4,0>. Rotated around the y-axis, this
  2972. would produce something like a gelatin mold - a rounded semi torus, hollow in
  2973. the middle. But with the SOR, as soon as the curve doubled back on itself in
  2974. the y-direction, it would become an illegal declaration.
  2975.  
  2976. Still, the SOR has one powerful strong point: because it uses simpler order
  2977. mathematics, it generally tends to render faster than an equivalent lathe. So
  2978. in the end, its a matter of: we use a SOR if its limitations will allow, but
  2979. when we need a more flexible shape, we go with the lathe instead.
  2980.  
  2981. 4.4.4.1          Understanding The Concept of Splines
  2982.  
  2983. It would be helpful, in order to understand splines, if we had a sort of
  2984. Spline Workshop where we could practice manipulating types and points of
  2985. splines and see what the effects were like. So let's make one! Now that we
  2986. know how to create a basic lathe, it will be easy (see file lathdem2.pov):
  2987.  
  2988.   #include "colors.inc"
  2989.  
  2990.   camera {
  2991.     orthographic
  2992.     up <0, 5, 0>
  2993.     right <5, 0, 0>
  2994.     location <2.5, 2.5, -100>
  2995.     look_at <2.5, 2.5, 0>
  2996.   }
  2997.  
  2998.   /* set the control points to be used */
  2999.  
  3000.   #declare Red_Point    = <1.00, 0.00, 0>
  3001.   #declare Orange_Point = <1.75, 1.00, 0>
  3002.   #declare Yellow_Point = <2.50, 2.00, 0>
  3003.   #declare Green_Point  = <2.00, 3.00, 0>
  3004.   #declare Blue_Point   = <1.50, 4.00, 0>
  3005.  
  3006.   /* make the control points visible */
  3007.  
  3008.   cylinder { Red_Point, Red_Point - 20*z, .1
  3009.     pigment { Red }
  3010.     finish { ambient 1 }
  3011.   }
  3012.  
  3013.   cylinder { Orange_Point, Orange_Point - 20*z, .1
  3014.     pigment { Orange }
  3015.     finish { ambient 1 }
  3016.   }
  3017.  
  3018.   cylinder { Yellow_Point, Yellow_Point - 20*z, .1
  3019.     pigment { Yellow }
  3020.     finish { ambient 1 }
  3021.   }
  3022.  
  3023.   cylinder { Green_Point, Green_Point - 20*z, .1
  3024.     pigment { Green }
  3025.     finish { ambient 1 }
  3026.   }
  3027.  
  3028.   cylinder { Blue_Point, Blue_Point- 20*z, .1
  3029.     pigment { Blue }
  3030.     finish { ambient 1 }
  3031.   }
  3032.  
  3033.   /* something to make the curve show up */
  3034.  
  3035.   lathe {
  3036.     linear_spline
  3037.     5,
  3038.     Red_Point,
  3039.     Orange_Point,
  3040.     Yellow_Point,
  3041.     Green_Point,
  3042.     Blue_Point
  3043.  
  3044.     pigment { White }
  3045.     finish { ambient 1 }
  3046.   }
  3047.  
  3048.  
  3049. A simple "Spline Workshop".
  3050.  
  3051. Now, we take a deep breath. We know that all looks a bit weird, but with some
  3052. simple explanations, we can easily see what all this does.
  3053.  
  3054. First, we are using the orthographic camera. If we haven't read up on that
  3055. yet, a quick summary is: it renders the scene flat, eliminating perspective
  3056. distortion so that in a side view, the objects look like they were drawn on a
  3057. piece of graph paper (like in the side view of a modeller or CAD package).
  3058. There are several uses for this practical new type of camera, but here it is
  3059. allowing us to see our lathe and cylinders edge on, so that what we see is
  3060. almost like a cross section of the curve which makes the lathe, rather than
  3061. the lathe itself. To further that effect, we eliminated shadowing with the
  3062. ambient 1 finish, which of course also eliminates the need for lighting. We
  3063. have also positioned this particular side view so that <0,0> appears at the
  3064. lower left of our scene.
  3065.  
  3066. Next, we declared a set of points. We note that we used 3D vectors for these
  3067. points rather than the 2D vectors we expect in a lathe. That's the exception
  3068. we mentioned earlier. When we declare a 3D point, then use it in a lathe, the
  3069. lathe only uses the first two components of the vector, and whatever is in
  3070. the third component is simply ignored. This is handy here, since it makes
  3071. this example possible.
  3072.  
  3073. Next we do two things with the declared points. First we use them to place
  3074. small diameter cylinders at the locations of the points with the circular
  3075. caps facing the camera. Then we re-use those same vectors to determine the
  3076. lathe. Since trying to declare a 2D vector can have some odd results, and
  3077. isn't really what our cylinder declarations need anyway, we can take
  3078. advantage of the lathe's tendancy to ignore the third component by just
  3079. setting the z-coordinate in these 3D vectors to zero.
  3080.  
  3081. The end result is: when we render this code, we see a white lathe against a
  3082. black background showing us how the curve we've declared looks, and the
  3083. circular ends of the cylinders show us where along the x-y-plane our control
  3084. points are. In this case, it's very simple. The linear spline has been used
  3085. so our curve is just straight lines zig-zagging between the points. We change
  3086. the declarations of Red_Point and Blue_Point to read as follows (see file
  3087. lathdem3.pov).
  3088.  
  3089.   #declare Red_Point  = <2.00, 0.00, 0>
  3090.   #declare Blue_Point = <0.00, 4.00, 0>
  3091.  
  3092.  
  3093. Moving some points of the spline.
  3094.  
  3095. We re-render and, as we can see, all that happens is that the straight line
  3096. segments just move to accomodate the new position of the red and blue points.
  3097. Linear splines are so simple, we could manipulate them in our sleep, no?
  3098.  
  3099. Let's try something different. First, we change the points to the following
  3100. (see file lathdem4.pov).
  3101.  
  3102.   #declare Red_Point    = <1.00, 0.00, 0>
  3103.   #declare Orange_Point = <2.00, 1.00, 0>
  3104.   #declare Yellow_Point = <3.50, 2.00, 0>
  3105.   #declare Green_Point  = <2.00, 3.00, 0>
  3106.   #declare Blue_Point   = <1.50, 4.00, 0>
  3107.  
  3108.  
  3109.  
  3110. A quadratic spline lathe.
  3111.  
  3112. We then go down to the lathe declaration and change linear_spline to
  3113. quadratic_spline. We re-render and what do we have? Well, there's a couple of
  3114. things worthy of note this time. First, we will see that instead of straight
  3115. lines we have smooth arcs connecting the points. These arcs are made from
  3116. quadratic curves, so our lathe looks much more interesting this time. Also,
  3117. Red_Point is no longer connected to the curve. What happened?
  3118.  
  3119. Well, while any two points can determine a straight line, it takes three to
  3120. determine a quadratic curve. POV-Ray looks not only to the two points to be
  3121. connected, but to the point immediately preceeding them to determine the
  3122. formula of the quadratic curve that will be used to connect them. The problem
  3123. comes in at the beginning of the curve. Beyond the first point in the curve
  3124. there is no previous point. So we need to declare one. Therefore, when using
  3125. a quadratic spline, we must remember that the first point we specify is only
  3126. there so that POV-Ray can determine what curve to connect the first two
  3127. points with. It will not show up as part of the actual curve.
  3128.  
  3129. There's just one more thing about this lathe example. Even though our curve
  3130. is now put together with smooth curving lines, the transitions between those
  3131. lines is... well, kind of choppy, no? This curve looks like the lines between
  3132. each individual point have been terribly mismatched. Depending on what we are
  3133. trying to make, this could be acceptable, or, we might long for a more
  3134. smoothly curving shape. Fortunately, if the latter is true, we have another
  3135. option.
  3136.  
  3137. The quadratic spline takes longer to render than a linear spline. The math is
  3138. more complex. Still longer needs the cubic spline, yet, for a really smoothed
  3139. out shape, this is the only way to go. We go back into our example, and
  3140. simply replace quadratic_spline with cubic_spline (see file lathdem5.pov). We
  3141. render one more time, and take a look at what we have.
  3142.  
  3143. A cubic spline lathe.
  3144.  
  3145. While a quadratic spline takes three points to determine the curve, a cubic
  3146. needs four. So, as we might expect, Blue_Point has now dropped out of the
  3147. curve, just as Red_Point did, as the first and last points of our curve are
  3148. now only control points for shaping the curves between the remaining points.
  3149. But look at the transition from Orange_Point to Yellow_Point and then back to
  3150. Green_Point. Now, rather than looking mismatched, our curve segements look
  3151. like one smoothly joined curve.
  3152.  
  3153. The concept of splines is a handy and necessary one, which will be seen again
  3154. in the prism and polygon objects. But with a little tinkering we can quickly
  3155. get a feel for working with them.
  3156.  
  3157. 4.4.5            Mesh Object
  3158.  
  3159. Mesh objects are very useful because they allow us to create objects
  3160. containing hundreds or thousands of triangles. Compared to a simple union of
  3161. triangles the mesh object stores the triangles more efficiently. Copies of
  3162. mesh objects need only a little additional memory because the triangles are
  3163. stored only once.
  3164.  
  3165. Almost every object can be approximated using triangles but we may need a lot
  3166. of triangles to create more complex shapes. Thus we will only create a very
  3167. simple mesh example. This example will show a very useful feature of the
  3168. triangles meshes though: a different texture can be assigned to each triangle
  3169. in the mesh.
  3170.  
  3171. Now let's begin. We will create a simple box with differently colored sides.
  3172. We create an empty file called meshdemo.pov and add the following lines.
  3173.  
  3174.   camera {
  3175.     location <20, 20, -50>
  3176.     look_at <0, 5, 0>
  3177.   }
  3178.  
  3179.   light_source { <50, 50, -50> color rgb<1, 1, 1> }
  3180.  
  3181.   #declare Red = texture {
  3182.     pigment { color rgb<0.8, 0.2, 0.2> }
  3183.     finish { ambient 0.2 diffuse 0.5 }
  3184.   }
  3185.  
  3186.   #declare Green = texture {
  3187.     pigment { color rgb<0.2, 0.8, 0.2> }
  3188.     finish { ambient 0.2 diffuse 0.5 }
  3189.   }
  3190.  
  3191.   #declare Blue = texture {
  3192.     pigment { color rgb<0.2, 0.2, 0.8> }
  3193.     finish { ambient 0.2 diffuse 0.5 }
  3194.   }
  3195.  
  3196.  
  3197. We must declare all textures we want to use inside the mesh before the mesh
  3198. is created. Textures cannot be specified inside the mesh due to the poor
  3199. memory performance that would result.
  3200.  
  3201. Now we add the mesh object. Three sides of the box will use individual
  3202. textures while the other will use the global mesh texture.
  3203.  
  3204.   mesh {
  3205.     /* top side */
  3206.     triangle { <-10, 10, -10>, <10, 10, -10>, <10, 10, 10>
  3207.       texture { Red }
  3208.     }
  3209.     triangle { <-10, 10, -10>, <-10, 10, 10>, <10, 10, 10>
  3210.       texture { Red }
  3211.     }
  3212.     /* bottom side */
  3213.     triangle { <-10, -10, -10>, <10, -10, -10>, <10, -10, 10> }
  3214.     triangle { <-10, -10, -10>, <-10, -10, 10>, <10, -10, 10> }
  3215.     /* left side */
  3216.     triangle { <-10, -10, -10>, <-10, -10, 10>, <-10, 10, 10> }
  3217.     triangle { <-10, -10, -10>, <-10, 10, -10>, <-10, 10, 10> }
  3218.     /* right side */
  3219.     triangle { <10, -10, -10>, <10, -10, 10>, <10, 10, 10>
  3220.       texture { Green }
  3221.     }
  3222.     triangle { <10, -10, -10>, <10, 10, -10>, <10, 10, 10>
  3223.       texture { Green }
  3224.     }
  3225.     /* front side */
  3226.     triangle { <-10, -10, -10>, <10, -10, -10>, <-10, 10, -10>
  3227.       texture { Blue }
  3228.     }
  3229.     triangle { <-10, 10, -10>, <10, 10, -10>, <10, -10, -10>
  3230.       texture { Blue }
  3231.     }
  3232.     /* back side */
  3233.     triangle { <-10, -10, 10>, <10, -10, 10>, <-10, 10, 10> }
  3234.     triangle { <-10, 10, 10>, <10, 10, 10>, <10, -10, 10> }
  3235.     texture {
  3236.       pigment { color rgb<0.9, 0.9, 0.9> }
  3237.       finish { ambient 0.2 diffuse 0.7 }
  3238.     }
  3239.   }
  3240.  
  3241.  
  3242. Tracing the scene at 320x240 we will see that the top, right and front side
  3243. of the box have different textures. Though this is not a very impressive
  3244. example it shows what we can do with mesh objects. More complex examples,
  3245. also using smooth triangles, can be found under the scene directory as
  3246. chesmsh.pov and robotmsh.pov.
  3247.  
  3248. 4.4.6            Polygon Object
  3249.  
  3250. The polygon object can be used to create any planar, n-sided shapes like
  3251. squares, rectangles, pentagons, hexagons, octagons, etc.
  3252.  
  3253. A polygon is defined by a number of points that describe its shape. Since
  3254. polygons have to be closed the first point has to be repeated at the end of
  3255. the point sequence.
  3256.  
  3257. In the following example we will create the word POV using just one polygon
  3258. statement.
  3259.  
  3260. We start with thinking about the points we need to describe the desired
  3261. shape. We want the letters to lie in the x-y-plane with the letter O being at
  3262. the center. The letters extend from y=0 to y=1. Thus we get the following
  3263. points for each letter (the z coordinate is automatically set to zero).
  3264.  
  3265. Letter P (outer polygon):
  3266.     <-0.8, 0.0>, <-0.8, 1.0>,
  3267.     <-0.3, 1.0>, <-0.3, 0.5>,
  3268.     <-0.7, 0.5>, <-0.7, 0.0>
  3269.  
  3270. Letter P (inner polygon):
  3271.     <-0.7, 0.6>, <-0.7, 0.9>,
  3272.     <-0.4, 0.9>, <-0.4, 0.6>
  3273.  
  3274. Letter O (outer polygon):
  3275.     <-0.25, 0.0>, <-0.25, 1.0>,
  3276.     < 0.25, 1.0>, < 0.25, 0.0>
  3277.  
  3278. Letter O (inner polygon):
  3279.     <-0.15, 0.1>, <-0.15, 0.9>,
  3280.     < 0.15, 0.9>, < 0.15, 0.1>
  3281.  
  3282. Letter V:
  3283.     <0.45, 0.0>, <0.30, 1.0>,
  3284.     <0.40, 1.0>, <0.55, 0.1>,
  3285.     <0.70, 1.0>, <0.80, 1.0>,
  3286.     <0.65, 0.0>
  3287.  
  3288.  
  3289. Both letters P and O have a hole while the letter V consists of only one
  3290. polygon. We'll start with the letter V because it is easier to define than
  3291. the other two letters.
  3292.  
  3293. We create a new file called polygdem.pov and add the following text.
  3294.  
  3295.   camera {
  3296.     orthographic
  3297.     location <0, 0, -10>
  3298.     right 1.3 * 4/3 * x
  3299.     up 1.3 * y
  3300.     look_at <0, 0.5, 0>
  3301.   }
  3302.  
  3303.   light_source { <25, 25, -100> color rgb 1 }
  3304.  
  3305.   polygon {
  3306.     8,
  3307.  
  3308.     <0.45, 0.0>, <0.30, 1.0>, // Letter "V"
  3309.     <0.40, 1.0>, <0.55, 0.1>,
  3310.     <0.70, 1.0>, <0.80, 1.0>,
  3311.     <0.65, 0.0>,
  3312.     <0.45, 0.0>
  3313.  
  3314.     pigment { color rgb <1, 0, 0> }
  3315.   }
  3316.  
  3317.  
  3318. As noted above the polygon has to be closed by appending the first point to
  3319. the point sequence. A closed polygon is always defined by a sequence of
  3320. points that ends when a point is the same as the first point.
  3321.  
  3322. After we have created the letter V we'll continue with the letter P. Since it
  3323. has a hole we have to find a way of cutting this hole into the basic shape.
  3324. This is quite easy. We just define the outer shape of the letter P, which is
  3325. a closed polygon, and add the sequence of points that describes the hole,
  3326. which is also a closed polygon. That's all we have to do. There'll be a hole
  3327. where both polygons overlap.
  3328.  
  3329. In general we will get holes whenever an even number of sub-polygons inside a
  3330. single polygon statement overlap. A sub-polygon is defined by a closed
  3331. sequence of points.
  3332.  
  3333. The letter P consists of two sub-polygons, one for the outer shape and one
  3334. for the hole. Since the hole polygon overlaps the outer shape polygon we'll
  3335. get a hole.
  3336.  
  3337. After we have understood how multiple sub-polygons in a single polygon
  3338. statement work, it is quite easy to add the missing O letter.
  3339.  
  3340. Finally, we get the complete word POV.
  3341.  
  3342.   polygon {
  3343.     30,
  3344.  
  3345.     <-0.8, 0.0>, <-0.8, 1.0>,    // Letter "P"
  3346.     <-0.3, 1.0>, <-0.3, 0.5>,    // outer shape
  3347.     <-0.7, 0.5>, <-0.7, 0.0>,
  3348.     <-0.8, 0.0>,
  3349.  
  3350.     <-0.7, 0.6>, <-0.7, 0.9>,    // whole
  3351.     <-0.4, 0.9>, <-0.4, 0.6>,
  3352.     <-0.7, 0.6>
  3353.  
  3354.     <-0.25, 0.0>, <-0.25, 1.0>,  // Letter "O"
  3355.     < 0.25, 1.0>, < 0.25, 0.0>,  // outer shape
  3356.     <-0.25, 0.0>,
  3357.  
  3358.     <-0.15, 0.1>, <-0.15, 0.9>,  // whole
  3359.     < 0.15, 0.9>, < 0.15, 0.1>,
  3360.     <-0.15, 0.1>,
  3361.  
  3362.     <0.45, 0.0>, <0.30, 1.0>,    // Letter "V"
  3363.     <0.40, 1.0>, <0.55, 0.1>,
  3364.     <0.70, 1.0>, <0.80, 1.0>,
  3365.     <0.65, 0.0>,
  3366.     <0.45, 0.0>
  3367.  
  3368.     pigment { color rgb <1, 0, 0> }
  3369.   }
  3370.  
  3371.  
  3372. 4.4.7            Prism Object
  3373.  
  3374. The prism is essentially a polygon or closed curve which is swept along a
  3375. linear path. We can imagine the shape so swept leaving a trail in space, and
  3376. the surface of that trail is the surface of our prism. The curve or polygon
  3377. making up a prism's face can be a composite of any number of sub-shapes, can
  3378. use any kind of three different splines, and can either keep a constant width
  3379. as it is swept, or slowly tapering off to a fine point on one end. But before
  3380. this gets too confusing, let's start one step at a time with the simplest
  3381. form of prism. We enter and render the following POV code (see file
  3382. prismdm1.pov).
  3383.  
  3384.   #include "colors.inc"
  3385.  
  3386.   camera {
  3387.     angle 20
  3388.     location <2, 10, -30>
  3389.     look_at <0, 1, 0>
  3390.   }
  3391.  
  3392.   light_source { <20, 20, -20> color White }
  3393.  
  3394.   prism {
  3395.     linear_sweep
  3396.     linear_spline
  3397.     0, // sweep the following shape from here ...
  3398.     1, // ... up through here
  3399.     7, // the number of points making up the shape ...
  3400.  
  3401.     <3,5>, <-3,5>, <-5,0>, <-3,-5>, <3, -5>, <5,0>, <3,5>
  3402.  
  3403.     pigment { Green }
  3404.   }
  3405.  
  3406.  
  3407. A hexagonal prism shape.
  3408.  
  3409. This produces a hexagonal polygon, which is then swept from y=0 through y=1.
  3410. In other words, we now have an extruded hexagon. One point to note is that
  3411. although this is a six sided figure, we have used a total of seven points.
  3412. That is because the polygon is supposed to be a closed shape, which we do
  3413. here by making the final point the same as the first. Technically, with
  3414. linear polygons, if we didn't do this, POV-Ray would automatically join the
  3415. two ends with a line to force it to close, although a warning would be
  3416. issued. However, this only works with linear splines, so we mustn't get too
  3417. casual about those warning messages!
  3418.  
  3419. 4.4.7.1          Teaching An Old Spline New Tricks
  3420.  
  3421. If we followed the section on splines covered under the lathe tutorial (see
  3422. section "Understanding The Concept of Splines"), we know that there are two
  3423. additional kinds of splines besides linear: the quadratic and the cubic
  3424. spline. Sure enough, we can use these with prisms to make a more free form,
  3425. smoothly curving type of prism.
  3426.  
  3427. There is just one catch, and we should read this section carefully to keep
  3428. from tearing our hair out over mysterious too few points in  prism messages
  3429. which keep our prism from rendering. We can probably guess where this is
  3430. heading: how to close a non-linear spline. Unlike the linear spline, which
  3431. simply draws a line between the last and first points if we forget to make
  3432. the last point equal to the first, quadratic and cubic splines are a little
  3433. more fussy.
  3434.  
  3435. First of all, we remember that quadratic splines determine the equation of
  3436. the curve which connects any two points based on those two points and the
  3437. previous point, so the first point in any quadratic spline is just a control
  3438. point and won't actually be part of the curve. What this means is: when we
  3439. make our shape out of a quadratic spline, we must match the second point to
  3440. the last, since the first point is not on the curve - it's just a control
  3441. point needed for computational purposes.
  3442.  
  3443. Likewise, cubic splines need both the first and last points to be control
  3444. points, therefore, to close a shape made with a cubic spline, we must match
  3445. the second point to the second from last point. If we don't match the correct
  3446. points on a quadratic or cubic shape, that's when we will get the too few
  3447. points in prism error. POV-Ray is still waiting for us to close the shape,
  3448. and when it runs out of points without seeing the closure, an error is
  3449. issued.
  3450.  
  3451. Confused? Okay, how about an example? We replace the prism in our last bit of
  3452. code with this one (see file prismdm2.pov).
  3453.  
  3454.   prism {
  3455.     cubic_spline
  3456.     0, // sweep the following shape from here ...
  3457.     1, // ... up through here
  3458.     6, // the number of points making up the shape ...
  3459.  
  3460.     < 3, -5>, // point#1 (control point... not on curve)
  3461.     < 3,  5>, // point#2  ... THIS POINT ...
  3462.     <-5,  0>, // point#3
  3463.     < 3, -5>, // point#4
  3464.     < 3,  5>, // point#5 ... MUST MATCH THIS POINT
  3465.     <-5,  0>  // point#6 (control point... not on curve)
  3466.  
  3467.     pigment { Green }
  3468.   }
  3469.  
  3470.  
  3471. A cubic, triangular prism shape.
  3472.  
  3473. This simple prism produces what looks like an extruded triangle with its
  3474. corners sanded smoothly off. Points two, three and four are the corners of
  3475. the triangle and point five closes the shape by returning to the location of
  3476. point two. As for points one and six, they are our control points, and aren't
  3477. part of the shape - they're just there to help compute what curves to use
  3478. between the other points.
  3479.  
  3480. 4.4.7.2          Smooth Transitions
  3481.  
  3482. Now a handy thing to note is that we have made point one equal point four,
  3483. and also point six equals point three. Yes, this is important. Although this
  3484. prism would still be legally closed if the control points were not what we've
  3485. made them, the curve transitions between points would not be as smooth. We
  3486. change points one and six to <4,6> and <0,7> respectively and re-render to
  3487. see how the back edge of the shape is altered (see file prismdm3.pov).
  3488.  
  3489. To put this more generally, if we want a smooth closure on a cubic spline, we
  3490. make the first control point equal to the third from last point, and the last
  3491. control point equal to the third point. On a quadratic spline, the trick is
  3492. similar, but since only the first point is a control point, make that equal
  3493. to the second from last point.
  3494.  
  3495. 4.4.7.3          Multiple Sub-Shapes
  3496.  
  3497. Just as with the polygon object (see section "Polygon Object") the prism is
  3498. very flexible, and allows us to make one prism out of several sub-prisms. To
  3499. do this, all we need to do is keep listing points after we have already
  3500. closed the first shape. The second shape can be simply an add on going off in
  3501. another direction from the first, but one of the more interesting features is
  3502. that if any even number of sub-shapes overlap, that region where they overlap
  3503. behaves as though it has been cut away from both sub-shapes. Let's look at
  3504. another example. Once again, same basic code as before for camera, light and
  3505. so forth, but we substitute this complex prism (see file prismdm4.pov).
  3506.  
  3507.   prism {
  3508.     linear_sweep
  3509.     cubic_spline
  3510.     0,  // sweep the following shape from here ...
  3511.     1,  // ... up through here
  3512.     18, // the number of points making up the shape ...
  3513.  
  3514.     <3,-5>, <3,5>, <-5,0>, <3, -5>, <3,5>, <-5,0>, // sub-shape #1
  3515.     <2,-4>, <2,4>, <-4,0>, <2,-4>, <2,4>, <-4,0>,  // sub-shape #2
  3516.     <1,-3>, <1,3>, <-3,0>, <1, -3>, <1,3>, <-3,0>  // sub-shape #3
  3517.  
  3518.     pigment { Green }
  3519.   }
  3520.  
  3521.  
  3522. Using sub-shapes to create a more complex shape.
  3523.  
  3524. For readability purposes, we have started a new line every time we moved on
  3525. to a new sub-shape, but the ray-tracer of course tells where each shape ends
  3526. based on whether the shape has been closed (as described earlier). We render
  3527. this new prism, and look what we've got. It's the same familiar shape, but it
  3528. now looks like a smaller version of the shape has been carved out of the
  3529. center, then the carved piece was sanded down even smaller and set back in
  3530. the hole.
  3531.  
  3532. Simply, the outer rim is where only sub-shape one exists, then the carved out
  3533. part is where sub-shapes one and two overlap. In the extreme center, the
  3534. object reappears because sub-shapes one, two, and three overlap, returning us
  3535. to an odd number of overlapping pieces. Using this technique we could make
  3536. any number of extremely complex prism shapes!
  3537.  
  3538. 4.4.7.4          Conic Sweeps And The Tapering Effect
  3539.  
  3540. In our original prism, the keyword linear_sweep is actually optional. This is
  3541. the default sweep assumed for a prism if no type of sweep is specified. But
  3542. there is another, extremely useful kind of sweep: the conic sweep. The basic
  3543. idea is like the original prism, except that while we are sweeping the shape
  3544. from the first height through the second height, we are constantly expanding
  3545. it from a single point until, at the second height, the shape has expanded to
  3546. the original points we made it from. To give a small idea of what such
  3547. effects are good for, we replace our existing prism with this (see file
  3548. prismdm5.pov):
  3549.  
  3550.   prism {
  3551.     conic_sweep
  3552.     linear_spline
  3553.     0, // height 1
  3554.     1, // height 2
  3555.     5, // the number of points making up the shape...
  3556.  
  3557.     <4,4>,<-4,4>,<-4,-4>,<4,-4>,<4,4>
  3558.  
  3559.     rotate <180, 0, 0>
  3560.     translate <0, 1, 0>
  3561.     scale <1, 4, 1>
  3562.     pigment { gradient y scale .2 }
  3563.   }
  3564.  
  3565.  
  3566. Creating a pyramid using conic sweeping.
  3567.  
  3568. The gradient pigment was selected to give some definition to our object
  3569. without having to fix the lights and the camera angle right at this moment,
  3570. but when we render it, we what we've created? A horizontally striped pyramid!
  3571. By now we can recognize the linear spline connecting the four points of a
  3572. square, and the familiar final point which is there to close the spline.
  3573.  
  3574. Notice all the transformations in the object declaration. That's going to
  3575. take a little explanation. The rotate and translate are easy. Normally, a
  3576. conic sweep starts full sized at the top, and tapers to a point at y=0, but
  3577. of course that would be upside down if we're making a pyramid. So we flip the
  3578. shape around the x-axis to put it rightside up, then since we actually
  3579. orbitted around the point, we translate back up to put it in the same
  3580. position it was in when we started.
  3581.  
  3582. The scale is to put the proportions right for this example. The base is eight
  3583. units by eight units, but the height (from y=1 to y=0) is only one unit, so
  3584. we've stretched it out a little. At this point, we're probably thinking, "why
  3585. not just sweep up from y=0 to y=4 and avoid this whole scaling thing?"
  3586.  
  3587. That is a very important gotcha! with conic sweeps. To see what's wrong with
  3588. that, let's try and put it into practice (see file prismdm6.pov). We must
  3589. make sure to remove the scale statement, and then replace the line which
  3590. reads
  3591.  
  3592.   1, // height 2
  3593. with
  3594.  
  3595.   1, // height 2
  3596.  
  3597.  
  3598. This sets the second height at y=4, so let's re-render and see if the effect
  3599. is the same.
  3600.  
  3601. Choosing a second height larger than one for the conic sweep.
  3602.  
  3603. Whoa! Our height is correct, but our pyramid's base is now huge! What went
  3604. wrong here? Simple. The base, as we described it with the points we used
  3605. actually occurs at y=1 no matter what we set the second height for. But if we
  3606. do set the second height higher than one, once the sweep passes y=1, it keeps
  3607. expanding outward along the same lines as it followed to our original base,
  3608. making the actual base bigger and bigger as it goes.
  3609.  
  3610. To avoid losing control of a conic sweep prism, it is usually best to let the
  3611. second height stay at y=1, and use a scale statement to adjust the height
  3612. from its unit size. This way we can always be sure the base's corners remain
  3613. where we think they are.
  3614.  
  3615. That leads to one more interesting thing about conic sweeps. What if we for
  3616. some reason don't want them to taper all the way to a point? What if instead
  3617. of a complete pyramid, we want more of a ziggurat step? Easily done. After
  3618. putting the second height back to one, and replacing our scale statment, we
  3619. change the line which reads
  3620.  
  3621.   0, // height 1
  3622. to
  3623.  
  3624.   0, // height 1
  3625.  
  3626.  
  3627. Increasing the first height for the conic sweep.
  3628.  
  3629. When we re-render, we see that the sweep stops short of going all the way to
  3630. its point, giving us a pyramid without a cap. Exactly how much of the cap is
  3631. cut off depends on how close the first height is to the second height.
  3632.  
  3633. 4.4.8            Superquadric Ellipsoid Object
  3634.  
  3635. Sometimes we want to make an object that does not have perfectly sharp edges
  3636. like a box does. Then, the superquadric ellipsoid is a useful object. It is
  3637. described by the simple syntax:
  3638.  
  3639.   superellipsoid { <r, n> }
  3640.  
  3641.  
  3642. Where r and n are float values greater than zero and less than or equal to
  3643. one. Let's make a superellipsoid and experiment with the values of r and n to
  3644. see what kind of shapes we can make.
  3645.  
  3646. We create a file called supellps.pov and edit it as follows:
  3647.  
  3648.   #include "colors.inc"
  3649.  
  3650.   camera {
  3651.     location <10, 5, -20>
  3652.     look_at 0
  3653.     angle 15
  3654.   }
  3655.  
  3656.   background { color rgb <.5, .5, .5> }
  3657.  
  3658.   light_source { <10, 50, -100> White }
  3659.  
  3660.  
  3661. The addition of a gray background makes it a little easier to see our object.
  3662. We now type:
  3663.  
  3664.   superellipsoid { <.25, .25>
  3665.     pigment { Red }
  3666.   }
  3667.  
  3668.  
  3669. We save the file and trace it at 200x150 -A to see the shape. It will look
  3670. like a box, but the edges will be rounded off. Now let's experiment with
  3671. different values of r and n. For the next trace, try <1, 0.2>. The shape now
  3672. looks like a cylinder, but the top edges are rounded. Now try <0.1, 1>. This
  3673. shape is an odd one! We don't know exactly what to call it, but it is
  3674. interesting. Finally, lets try <1, 1>. Well, this is more familiar... a
  3675. sphere!
  3676.  
  3677. There are a couple of facts about superellipsoids we should know. First, we
  3678. should not use a value of 0 for either r nor n. This will cause POV-Ray to
  3679. incorrectly make a black box instead of our desired shape. Second, very small
  3680. values of r and n may yield strange results so they should be avoided.
  3681. Finally, the Sturmian root solver will not work with superellipsoids.
  3682.  
  3683. Superellipsoids are finite objects so they respond to auto-bounding and can
  3684. be used in CSG.
  3685.  
  3686. Now let's use the superellipsoid to make something that would be useful in a
  3687. scene. We will make a tiled floor and place a couple of superellipsoid
  3688. objects hovering over it. We can start with the file we have already made.
  3689.  
  3690. We rename it to tiles.pov and edit it so that it reads as follows:
  3691.  
  3692.   #include "colors.inc"
  3693.   #include "textures.inc"
  3694.  
  3695.   camera {
  3696.     location <10, 5, -20>
  3697.     look_at 0
  3698.     angle 15
  3699.   }
  3700.   background { color rgb <.5, .5, .5> }
  3701.  
  3702.   light_source{ <10, 50, -100> White }
  3703.  
  3704.  
  3705. Note that we have added #include "textures.inc" so we can use pre-defined
  3706. textures. Now we want to define the superellipsoid which will be our tile.
  3707.  
  3708.   #declare Tile = superellipsoid { <0.5, 0.1>
  3709.     scale <1, .05, 1>
  3710.   }
  3711.  
  3712.  
  3713. Superellipsoids are roughly 2*2*2 units unless we scale them otherwise. If we
  3714. wish to lay a bunch of our tiles side by side, they will have to be offset
  3715. from each other so they don't overlap. We should select an offset value that
  3716. is slightly more than 2 so that we have some space between the tiles to fill
  3717. with grout. So we now add this:
  3718.  
  3719.   #declare Offset = 2.1
  3720.  
  3721.  
  3722. We now want to lay down a row of tiles. Each tile will be offset from the
  3723. original by an ever-increasing amount in both the +z and -z directions. We
  3724. refer to our offset and multiply by the tile's rank to determine the position
  3725. of each tile in the row. We also union these tiles into a single object
  3726. called Row like this:
  3727.  
  3728.   #declare Row = union {
  3729.     object { Tile }
  3730.     object { Tile translate z*Offset }
  3731.     object { Tile translate z*Offset*2 }
  3732.     object { Tile translate z*Offset*3 }
  3733.     object { Tile translate z*Offset*4 }
  3734.     object { Tile translate z*Offset*5 }
  3735.     object { Tile translate z*Offset*6 }
  3736.     object { Tile translate z*Offset*7 }
  3737.     object { Tile translate z*Offset*8 }
  3738.     object { Tile translate z*Offset*9 }
  3739.     object { Tile translate z*Offset*10 }
  3740.     object { Tile translate -z*Offset }
  3741.     object { Tile translate -z*Offset*2 }
  3742.     object { Tile translate -z*Offset*3 }
  3743.     object { Tile translate -z*Offset*4 }
  3744.     object { Tile translate -z*Offset*5 }
  3745.     object { Tile translate -z*Offset*6 }
  3746.   }
  3747.  
  3748.  
  3749. This gives us a single row of 17 tiles, more than enough to fill the screen.
  3750. Now we must make copies of the Row and translate them, again by the offset
  3751. value, in both the +x and -x directions in ever increasing amounts in the
  3752. same manner.
  3753.  
  3754.   object { Row }
  3755.   object { Row translate x*Offset }
  3756.   object { Row translate x*Offset*2 }
  3757.   object { Row translate x*Offset*3 }
  3758.   object { Row translate x*Offset*4 }
  3759.   object { Row translate x*Offset*5 }
  3760.  
  3761.   object { Row translate x*Offset*6 }
  3762.   object { Row translate x*Offset*7 }
  3763.   object { Row translate -x*Offset }
  3764.   object { Row translate -x*Offset*2 }
  3765.   object { Row translate -x*Offset*3 }
  3766.   object { Row translate -x*Offset*4 }
  3767.   object { Row translate -x*Offset*5 }
  3768.   object { Row translate -x*Offset*6 }
  3769.   object { Row translate -x*Offset*7 }
  3770.  
  3771.  
  3772. Finally, our tiles are complete. But we need a texture for them. To do this
  3773. we union all of the Rows together and apply a White Marble pigment and a
  3774. somewhat shiny reflective surface to it:
  3775.  
  3776.   union{
  3777.     object { Row }
  3778.     object { Row translate x*Offset }
  3779.     object { Row translate x*Offset*2 }
  3780.     object { Row translate x*Offset*3 }
  3781.     object { Row translate x*Offset*4 }
  3782.     object { Row translate x*Offset*5 }
  3783.     object { Row translate x*Offset*6 }
  3784.     object { Row translate x*Offset*7 }
  3785.     object { Row translate -x*Offset }
  3786.     object { Row translate -x*Offset*2 }
  3787.     object { Row translate -x*Offset*3 }
  3788.     object { Row translate -x*Offset*4 }
  3789.     object { Row translate -x*Offset*5 }
  3790.     object { Row translate -x*Offset*6 }
  3791.     object { Row translate -x*Offset*7 }
  3792.     pigment { White_Marble }
  3793.     finish { phong 1 phong_size 50 reflection .35 }
  3794.   }
  3795.  
  3796.  
  3797. We now need to add the grout. This can simply be a white plane. We have
  3798. stepped up the ambient here a little so it looks whiter.
  3799.  
  3800.   plane { y, 0  //this is the grout
  3801.     pigment { color White }
  3802.     finish { ambient .4 diffuse .7 }
  3803.   }
  3804.  
  3805.  
  3806. To complete our scene, let's add five different superellipsoids, each a
  3807. different color, so that they hover over our tiles and are reflected in them.
  3808.  
  3809.  
  3810.   superellipsoid {
  3811.     <0.1, 1>
  3812.     pigment { Red }
  3813.     translate <5, 3, 0>
  3814.     scale .45
  3815.   }
  3816.  
  3817.   superellipsoid {
  3818.     <1, 0.25>
  3819.     pigment { Blue }
  3820.     translate <-5, 3, 0>
  3821.     scale .45
  3822.   }
  3823.  
  3824.   superellipsoid {
  3825.     <0.2, 0.6>
  3826.     pigment { Green }
  3827.     translate <0, 3, 5>
  3828.     scale .45
  3829.   }
  3830.  
  3831.   superellipsoid {
  3832.     <0.25, 0.25>
  3833.     pigment { Yellow }
  3834.     translate <0, 3, -5>
  3835.     scale .45
  3836.   }
  3837.  
  3838.   superellipsoid {
  3839.     <1, 1>
  3840.     pigment { Pink }
  3841.     translate y*3
  3842.     scale .45
  3843.   }
  3844.  
  3845.  
  3846. Some superellipsoids hovering above a tiled floor.
  3847.  
  3848. We trace the scene at 320x200 -A to see the result. If we are happy with
  3849. that, we do a final trace at 640x480 +A0.2.
  3850.  
  3851. 4.4.9            Surface of Revolution Object
  3852.  
  3853. Bottles, vases and glasses make nice objects in ray-traced scenes. We want to
  3854. create a golden cup using the surface of revolution object (SOR object).
  3855.  
  3856. We first start by thinking about the shape of the final object. It is quite
  3857. difficult to come up with a set of points that describe a given curve without
  3858. the help of a modelling program supporting POV-Eay's surface of revolution
  3859. object. If such a program is available we should take advantage of it.
  3860.  
  3861. The point configuration of our cup object.
  3862.  
  3863. We will use the point configuration shown in the figure above. There are
  3864. eight points describing the curve that will be rotated about the y-axis to
  3865. get our cup. The curve was calculated using the method described in the
  3866. reference section (see "Surface of Revolution").
  3867.  
  3868. Now it is time to come up with a scene that uses the above SOR object. We
  3869. edit a file called sordemo.pov and enter the following text.
  3870.  
  3871.   #include "colors.inc"
  3872.   #include "golds.inc"
  3873.  
  3874.   global_settings { assumed_gamma 2.2 }
  3875.  
  3876.   camera {
  3877.     location <10, 15, -20>
  3878.     look_at <0, 5, 0>
  3879.     angle 45
  3880.   }
  3881.  
  3882.   background { color rgb<0.2, 0.4, 0.8>  }
  3883.  
  3884.   light_source { <100, 100, -100> color rgb 1 }
  3885.  
  3886.   plane { y, 0
  3887.     pigment { checker color Red, color Green scale 10 }
  3888.   }
  3889.  
  3890.   sor {
  3891.     8,
  3892.     <0.0,  -0.5>,
  3893.     <3.0,   0.0>,
  3894.     <1.0,   0.2>,
  3895.     <0.5,   0.4>,
  3896.     <0.5,   4.0>,
  3897.     <1.0,   5.0>,
  3898.     <3.0,  10.0>,
  3899.     <4.0,  11.0>
  3900.     texture { T_Gold_1B }
  3901.   }
  3902.  
  3903.  
  3904. The scene contains our cup object resting on a checkered plane. Tracing this
  3905. scene at a resolution of 320x200 results in the image below.
  3906.  
  3907. A surface of revolution object.
  3908.  
  3909. The surface of revolution is described by starting with the number of points
  3910. followed by the points with ascending heights. Each point determines the
  3911. radius the curve for a given height. E. g. the first point tells POV-Ray that
  3912. at height -0.5 the radius is 0. We should take care that each point has a
  3913. larger height than its predecessor. If this is not the case the program will
  3914. abort with an error message.
  3915.  
  3916. 4.4.10           Text Object
  3917.  
  3918. Creating text objects using POV-Ray always used to mean that the letters had
  3919. to be built either from CSG, a painstaking process or by using a black and
  3920. white image of the letters as a height field, a method that was only somewhat
  3921. satisfactory. Now, for POV-Ray 3.0, a new primitive has been introduced that
  3922. can use any TrueType font to create text objects. These objects can be used
  3923. in CSG, transformed and textured just like any other POV primitive.
  3924.  
  3925. For this tutorial, we will make two uses of the text object. First, let's
  3926. just make some block letters sitting on a checkered plane. Any TTF font
  3927. should do, but for this tutorial, we will use the ones bundled with POV-Ray
  3928. 3.0.
  3929.  
  3930. We create a file called textdemo.pov and edit it as follows:
  3931.  
  3932.   #include "colors.inc"
  3933.  
  3934.   camera {
  3935.     location <0, 1, -10>
  3936.     look_at 0
  3937.     angle 35
  3938.   }
  3939.  
  3940.   light_source { <500,500,-1000> White }
  3941.  
  3942.   plane { y,0
  3943.     pigment { checker Green White }
  3944.   }
  3945.  
  3946.  
  3947. Now let's add the text object. We will use the font timrom.ttf and we will
  3948. create the string POV-RAY 3.0. For now, we will just make the letters red.
  3949. The syntax is very simple. The first string in quotes is the font name, the
  3950. second one is the string to be rendered. The two floats are the thickness and
  3951. offset values. The thickness float determines how thick the block letters
  3952. will be. Values of .5 to 2 are usually best for this. The offset value will
  3953. add to the kerning distance of the letters. We will leave this a 0 for now.
  3954.  
  3955.   text { ttf "timrom.ttf" "POV-RAY 3.0" 1, 0
  3956.     pigment { Red }
  3957.   }
  3958.  
  3959.  
  3960. Rendering this at 200x150 -A, we notice that the letters are off to the right
  3961. of the screen. This is because they are placed so that the lower left front
  3962. corner of the first letter is at the origin. To center the string we need to
  3963. translate it -x some distance. But how far? In the docs we see that the
  3964. letters are all 0.5 to 0.75 units high. If we assume that each one takes
  3965. about 0.5 units of space on the x-axis, this means that the string is about 6
  3966. units long (12 characters and spaces). Let's translate the string 3 units
  3967. along the negative x-axis.
  3968.  
  3969.   text { ttf "timrom.ttf" "POV-RAY 3.0" 1, 0
  3970.     pigment { Red }
  3971.     translate -3*x
  3972.   }
  3973.  
  3974.  
  3975. That's better. Now let's play around with some of the parameters of the text
  3976. object. First, let's raise the thickness float to something outlandish... say
  3977. 25!
  3978.  
  3979.   text { ttf "timrom.ttf" "POV-RAY 3.0" 25, 0
  3980.     pigment { Red }
  3981.     translate -2.25*x
  3982.   }
  3983.  
  3984.  
  3985. Actually, that's kind of cool. Now let's return the thickness value to 1 and
  3986. try a different offset value. Change the offset float from 0 to 0.1 and
  3987. render it again.
  3988.  
  3989. Wait a minute?! The letters go wandering off up at an angle! That is not what
  3990. the docs describe! It almost looks as if the offset value applies in both the
  3991. x- and y-axis instead of just the x axis like we intended. Could it be that a
  3992. vector is called for here instead of a float? Let's try it. We replace 0.1
  3993. with 0.1*x and render it again.
  3994.  
  3995. That works! The letters are still in a straight line along the x-axis, just a
  3996. little further apart. Let's verify this and try to offset just in the y-axis.
  3997. We replace 0.1*x with 0.1*y. Again, this works as expected with the letters
  3998. going up to the right at an angle with no additional distance added along the
  3999. x-axis. Now let's try the z-axis. We replace 0.1*y with 0.1*z. Rendering this
  4000. yields a disappointment. No offset occurs! The offset value can only be
  4001. applied in the x- and y-directions.
  4002.  
  4003. Let's finish our scene by giving a fancier texture to the block letters,
  4004. using that cool large thickness value, and adding a slight y-offset. For fun,
  4005. we will throw in a sky sphere, dandy up our plane a bit, and use a little
  4006. more interesting camera viewpoint (we render the following scene at 640x480
  4007. +A0.2):
  4008.  
  4009.   #include "colors.inc"
  4010.  
  4011.   camera {
  4012.     location <-5,.15,-2>
  4013.     look_at <.3,.2,1>
  4014.     angle 35
  4015.   }
  4016.  
  4017.   light_source { <500,500,-1000> White }
  4018.  
  4019.   plane { y,0
  4020.     texture {
  4021.       pigment { SeaGreen }
  4022.       finish { reflection .35 specular 1 }
  4023.       normal { ripples .35 turbulence .5 scale .25 }
  4024.     }
  4025.   }
  4026.  
  4027.   text { ttf "timrom.ttf" "POV-RAY 3.0" 25, 0.1*y
  4028.     pigment { BrightGold }
  4029.     finish { reflection .25 specular 1 }
  4030.     translate -3*x
  4031.   }
  4032.  
  4033.   #include "skies.inc"
  4034.  
  4035.   sky_sphere { S_Cloud5 }
  4036.  
  4037.  
  4038. Let's try using text in a CSG object. We will attempt to create an inlay in a
  4039. stone block using a text object. We create a new file called textcsg.pov and
  4040. edit it as follows:
  4041.  
  4042.   #include "colors.inc"
  4043.  
  4044.   #include "stones.inc"
  4045.  
  4046.   background { color rgb 1 }
  4047.  
  4048.   camera {
  4049.     location <-3, 5, -15>
  4050.     look_at 0
  4051.     angle 25
  4052.   }
  4053.  
  4054.   light_source { <500,500,-1000> White }
  4055.  
  4056.  
  4057. Now let's create the block. We want it to be about eight units across because
  4058. our text string (POV-RAY 3.0) is about six units long. We also want it about
  4059. four units high and about one unit deep. But we need to avoid a potential
  4060. coincident surface with the text object so we will make the first
  4061. z-coordinate 0.1 instead of 0. Finally, we will give this block a nice stone
  4062. texture.
  4063.  
  4064.   box { <-3.5, -1, 0.1>, <3.5, 1, 1>
  4065.     texture { T_Stone10 }
  4066.   }
  4067.  
  4068.  
  4069. Next, we want to make the text object. We can use the same object we used in
  4070. the first tutorial except we will use slightly different thickness and offset
  4071. values.
  4072.  
  4073.   text { ttf "timrom.ttf" "POV-RAY 3.0" 0.15, 0
  4074.     pigment { BrightGold }
  4075.     finish { reflection .25 specular 1 }
  4076.     translate -3*x
  4077.   }
  4078.  
  4079.  
  4080. We remember that the text object is placed by default so that its front
  4081. surface lies directly on the x-y-plane. If the front of the box begins at
  4082. z=0.1 and thickness is set at 0.15, the depth of the inlay will be 0.05
  4083. units. We place a difference block around the two objects.
  4084.  
  4085.   difference {
  4086.     box { <-3.5, -1, 0.1>, <3.5, 1, 1>
  4087.       texture { T_Stone10 }
  4088.     }
  4089.     text { ttf "timrom.ttf" "POV-RAY 3.0" 0.15, 0
  4090.       pigment { BrightGold }
  4091.       finish { reflection .25 specular 1 }
  4092.       translate -3*x
  4093.     }
  4094.   }
  4095.  
  4096.  
  4097. Text carved from stone.
  4098.  
  4099. We render this at 200x150 -A. We can see the inlay clearly and that it is
  4100. indeed a bright gold color. We re-render at 640x480 +A0.2 to see the results
  4101. more clearly, but be forewarned... this trace will take a little time.
  4102.  
  4103. 4.4.11           Torus Object
  4104.  
  4105. A torus can be thought of as a donut or an inner-tube. It is a shape that is
  4106. vastly useful in many kinds of CSG so POV-Ray has adopted this 4th order
  4107. quartic polynomial as a primitive shape. The syntax for a torus is so simple
  4108. that it makes it a very easy shape to work with once we learn what the two
  4109. float values mean. Instead of a lecture on the subject, let's create one and
  4110. do some experiments with it.
  4111.  
  4112. We create a file called tordemo.pov and edit it as follows:
  4113.  
  4114.   #include "colors.inc"
  4115.  
  4116.   camera {
  4117.     location <0, .1, -25>
  4118.     look_at 0
  4119.     angle 30
  4120.   }
  4121.  
  4122.   background { color Gray50 } // to make the torus easy to see
  4123.  
  4124.   light_source{ <300, 300, -1000> White }
  4125.  
  4126.   torus { 4, 1        // major and minor radius
  4127.     rotate -90*x      // so we can see it from the top
  4128.     pigment { Green }
  4129.   }
  4130.  
  4131.  
  4132. We trace the scene. Well, it's a donut alright. Let's try changing the major
  4133. and minor radius values and see what happens. We change them as follows:
  4134.  
  4135.   torus { 5, .25      // major and minor radius
  4136.  
  4137.  
  4138. That looks more like a hula-hoop! Let's try this:
  4139.  
  4140.   torus { 3.5, 2.5    // major and minor radius
  4141.  
  4142.  
  4143. Whoa! A donut with a serious weight problem!
  4144.  
  4145. With such a simple syntax, there isn't much else we can do to a torus besides
  4146. change its texture... or is there? Let's see...
  4147.  
  4148. Torii are very useful objects in CSG. Let's try a little experiment. We make
  4149. a difference of a torus and a box:
  4150.  
  4151.   difference {
  4152.     torus { 4, 1
  4153.       rotate x*-90  // so we can see it from the top
  4154.     }
  4155.     box { <-5, -5, -1>, <5, 0, 1> }
  4156.     pigment { Green }
  4157.   }
  4158.  
  4159.  
  4160. Interesting... a half-torus. Now we add another one flipped the other way.
  4161. Only, let's declare the original half-torus and the necessary transformations
  4162. so we can use them again:
  4163.  
  4164.   #declare Half_Torus = difference {
  4165.     torus { 4, 1
  4166.       rotate -90*x  // so we can see it from the top
  4167.     }
  4168.     box { <-5, -5, -1>, <5, 0, 1> }
  4169.     pigment { Green }
  4170.   }
  4171.  
  4172.   #declare Flip_It_Over = 180*x
  4173.  
  4174.   #declare Torus_Translate = 8  // twice the major radius
  4175.  
  4176.  
  4177. Now we create a union of two Half_Torus objects:
  4178.  
  4179.   union {
  4180.     object { Half_Torus }
  4181.     object { Half_Torus
  4182.       rotate Flip_It_Over
  4183.       translate Torus_Translate*x
  4184.     }
  4185.   }
  4186.  
  4187.  
  4188. This makes an S-shaped object, but we can't see the whole thing from our
  4189. present camera. Let's add a few more links, three in each direction, move the
  4190. object along the +z-direction and rotate it about the +y-axis so we can see
  4191. more of it. We also notice that there appears to be a small gap where the
  4192. half torii meet. This is due to the fact that we are viewing this scene from
  4193. directly on the x-z-plane. We will change the camera's y-coordinate from 0 to
  4194. 0.1 to eliminate this.
  4195.  
  4196.   union {
  4197.     object { Half_Torus }
  4198.     object { Half_Torus
  4199.       rotate Flip_It_Over
  4200.       translate x*Torus_Translate
  4201.     }
  4202.     object { Half_Torus
  4203.       translate x*Torus_Translate*2
  4204.     }
  4205.     object { Half_Torus
  4206.       rotate Flip_It_Over
  4207.       translate x*Torus_Translate*3
  4208.     }
  4209.     object { Half_Torus
  4210.       rotate Flip_It_Over
  4211.       translate -x*Torus_Translate
  4212.     }
  4213.     object { Half_Torus
  4214.       translate -x*Torus_Translate*2
  4215.     }
  4216.     object { Half_Torus
  4217.       rotate Flip_It_Over
  4218.       translate -x*Torus_Translate*3
  4219.     }
  4220.     object { Half_Torus
  4221.       translate -x*Torus_Translate*4
  4222.     }
  4223.     rotate y*45
  4224.     translate z*20
  4225.   }
  4226.  
  4227.  
  4228. Rendering this we see a cool, undulating, snake-like something-or-other.
  4229. Neato. But we want to model something useful, something that we might see in
  4230. real
  4231. life. How about a chain?
  4232.  
  4233. Thinking about it for a moment, we realize that a single link of a chain can
  4234. be easily modeled using two half toruses and two cylinders. We create a new
  4235. file. We can use the same camera, background, light source and declared
  4236. objects and transformations as we used in tordemo.pov:
  4237.  
  4238.   #include "colors.inc"
  4239.  
  4240.   camera {
  4241.     location <0, .1, -25>
  4242.     look_at 0
  4243.     angle 30
  4244.   }
  4245.  
  4246.   background { color Gray50 }
  4247.  
  4248.   light_source{ <300, 300, -1000> White }
  4249.  
  4250.   #declare Half_Torus = difference {
  4251.     torus { 4,1
  4252.       sturm
  4253.       rotate x*-90  // so we can see it from the top
  4254.     }
  4255.     box { <-5, -5, -1>, <5, 0, 1> }
  4256.     pigment { Green }
  4257.   }
  4258.  
  4259.   #declare Flip_It_Over = x*180
  4260.  
  4261.   #declare Torus_Translate = 8
  4262.  
  4263.  
  4264. Now, we make a complete torus of two half toruses:
  4265.  
  4266.   union {
  4267.     object { Half_Torus }
  4268.     object { Half_Torus rotate Flip_It_Over }
  4269.   }
  4270.  
  4271.  
  4272. This may seem like a wasteful way to make a complete torus, but we are really
  4273. going to move each half apart to make room for the cylinders. First, we add
  4274. the declared cylinder before the union:
  4275.  
  4276.   #declare Chain_Segment = cylinder { <0, 4, 0>, <0, -4, 0>, 1
  4277.     pigment { Green }
  4278.   }
  4279.  
  4280.  
  4281. We then add two chain segments to the union and translate them so that they
  4282. line up with the minor radius of the torus on each side:
  4283.  
  4284.   union {
  4285.     object { Half_Torus }
  4286.     object { Half_Torus rotate Flip_It_Over }
  4287.     object { Chain_Segment translate  x*Torus_Translate/2 }
  4288.     object { Chain_Segment translate -x*Torus_Translate/2 }
  4289.   }
  4290.  
  4291.  
  4292. Now we translate the two half toruses +y and -y so that the clipped ends meet
  4293. the ends of the cylinders. This distance is equal to half of the previously
  4294. declared Torus_Translate:
  4295.  
  4296.   union {
  4297.     object { Half_Torus
  4298.       translate y*Torus_Translate/2
  4299.     }
  4300.     object { Half_Torus
  4301.       rotate Flip_It_Over
  4302.       translate -y*Torus_Translate/2
  4303.     }
  4304.     object { Chain_Segment
  4305.       translate x*Torus_Translate/2
  4306.     }
  4307.     object { Chain_Segment
  4308.       translate -x*Torus_Translate/2
  4309.     }
  4310.   }
  4311.  
  4312.  
  4313. We render this and viola! A single link of a chain. But we aren't done yet!
  4314. Whoever heard of a green chain? We would rather use a nice metallic color
  4315. instead. First, we remove any pigment blocks in the declared toruses and
  4316. cylinders. Then we add the following before the union:
  4317.  
  4318.   #declare Chain_Gold = texture {
  4319.     pigment { BrightGold }
  4320.     finish {
  4321.       ambient .1
  4322.       diffuse .4
  4323.       reflection .25
  4324.       specular 1
  4325.       metallic
  4326.     }
  4327.   }
  4328.  
  4329.  
  4330. We then add the texture to the union and declare the union as a single link:
  4331.  
  4332.   #declare Link = union {
  4333.     object { Half_Torus
  4334.       translate y*Torus_Translate/2
  4335.     }
  4336.     object { Half_Torus
  4337.       rotate Flip_It_Over
  4338.       translate -y*Torus_Translate/2
  4339.     }
  4340.     object { Chain_Segment
  4341.       translate x*Torus_Translate/2
  4342.     }
  4343.     object { Chain_Segment
  4344.       translate -x*Torus_Translate/2
  4345.     }
  4346.     texture { Chain_Gold }
  4347.   }
  4348.  
  4349.  
  4350. Now we make a union of two links. The second one will have to be translated
  4351. +y so that its inner wall just meets the inner wall of the other link, just
  4352. like the links of a chain. This distance turns out to be double the
  4353. previously declared Torus_Translate minus 2 (twice the minor radius). This
  4354. can be described by the expression:
  4355.  
  4356.   Torus_Translate*2-2*y
  4357.  
  4358.  
  4359.  
  4360. We declare this expression as follows:
  4361.  
  4362.   #declare Link_Translate = Torus_Translate*2-2*y
  4363.  
  4364.  
  4365. In the object block, we will use this declared value so that we can multiply
  4366. it to create other links. Now, we rotate the second link 90*y so that it is
  4367. perpendicular to the first, just like links of a chain. Finally, we scale the
  4368. union by 1/4 so that we can see the whole thing:
  4369.  
  4370.   union {
  4371.     object { Link }
  4372.     object { Link translate y*Link_Translate rotate y*90 }
  4373.     scale .25
  4374.   }
  4375.  
  4376.  
  4377. We render this and we will see a very realistic pair of links. If we want to
  4378. make an entire chain, we must declare the above union and then create another
  4379. union of this declared object. We must be sure to remove the scaling from the
  4380. declared object:
  4381.  
  4382.   #declare Link_Pair =
  4383.   union {
  4384.     object { Link }
  4385.     object { Link translate y*Link_Translate rotate y*90 }
  4386.   }
  4387.  
  4388.  
  4389. Now we declare our chain:
  4390.  
  4391.   #declare Chain = union {
  4392.     object { Link_Pair}
  4393.     object { Link_Pair translate  y*Link_Translate*2 }
  4394.     object { Link_Pair translate  y*Link_Translate*4 }
  4395.     object { Link_Pair translate  y*Link_Translate*6 }
  4396.     object { Link_Pair translate -y*Link_Translate*2 }
  4397.     object { Link_Pair translate -y*Link_Translate*4 }
  4398.     object { Link_Pair translate -y*Link_Translate*6 }
  4399.   }
  4400.  
  4401.  
  4402. And finally we create our chain with a couple of transformations to make it
  4403. easier to see. These include scaling it down by a factor of 1/10, and
  4404. rotating it so that we can clearly see each link:
  4405.  
  4406.   object { Chain scale .1 rotate <0, 45, -45> }
  4407.  
  4408.  
  4409. The torus object can be used to create chains.
  4410.  
  4411. We render this and we should see a very realistic gold chain stretched
  4412. diagonally across the screen.
  4413.  
  4414. 4.5              CSG Objects
  4415.  
  4416. Constructive Solid Geometry, CSG, is a powerful tool to combine primitive
  4417. objects to create more complex objects as shown in the following sections.
  4418.  
  4419. 4.5.1            What is CSG?
  4420.  
  4421. CSG stands for Constructive Solid Geometry. POV-Ray allows us to construct
  4422. complex solids by combining primitive shapes in four different ways. These
  4423. are union, where two or more shapes are added together. Intersection, where
  4424. two or more shapes are combined to make a new shape that consists of the area
  4425. common to both shapes. Difference, where subsequent shapes are subtracted
  4426. from the first shape. And last not least merge, which is like a union where
  4427. the surfaces inside the union are removed (useful in transparent CSG
  4428. objects). We will deal with each of these in detail in the next few sections.
  4429.  
  4430.  
  4431. CSG objects can be extremely complex. They can be deeply nested. In other
  4432. words there can be unions of differences or intersections of merges or
  4433. differences of intersections or even unions of intersections of differences
  4434. of merges... ad infinitum. CSG objects are (almost always) finite objects and
  4435. thus respond to auto-bounding and can be transformed like any other POV
  4436. primitive shape.
  4437.  
  4438. 4.5.2            CSG Union
  4439.  
  4440. Let's try making a simple union. Create a file called csgdemo.pov and edit it
  4441. as follows:
  4442.  
  4443.   #include "colors.inc"
  4444.  
  4445.   camera {
  4446.     location <0, 1, -10>
  4447.     look_at 0
  4448.     angle 36
  4449.   }
  4450.  
  4451.   light_source { <500, 500, -1000> White }
  4452.  
  4453.   plane { y, -1.5
  4454.     pigment { checker Green White }
  4455.   }
  4456.  
  4457.  
  4458. Let's add two spheres each translated 0.5 units along the x-axis in each
  4459. direction. We color one blue and the other red.
  4460.  
  4461.   sphere { <0, 0, 0>, 1
  4462.     pigment { Blue }
  4463.     translate -0.5*x
  4464.   }
  4465.   sphere { <0, 0, 0>, 1
  4466.     pigment { Red }
  4467.     translate 0.5*x
  4468.   }
  4469.  
  4470.  
  4471. We trace this file at 200x150 -A. Now we place a union block around the two
  4472. spheres. This will create a single CSG union out of the two objects.
  4473.  
  4474.   union{
  4475.     sphere { <0, 0, 0>, 1
  4476.       pigment { Blue }
  4477.       translate -0.5*x
  4478.     }
  4479.     sphere { <0, 0, 0>, 1
  4480.       pigment { Red }
  4481.       translate 0.5*x
  4482.     }
  4483.   }
  4484.  
  4485.  
  4486. We trace the file again. The union will appear no different from what each
  4487. sphere looked like on its own, but now we can give the entire union a single
  4488. texture and transform it as a whole. Let's do that now.
  4489.  
  4490.   union{
  4491.     sphere { <0, 0, 0>, 1
  4492.       translate -0.5*x*
  4493.     }
  4494.     sphere { <0, 0, 0>, 1
  4495.       translate 0.5*x
  4496.     }
  4497.     pigment { Red }
  4498.     scale <1, .25, 1>
  4499.     rotate <30, 0, 45>
  4500.   }
  4501.  
  4502.  
  4503. We trace the file again. As we can see, the object has changed dramatically.
  4504. We experiment with different values of scale and rotate and try some
  4505. different textures.
  4506.  
  4507. There are many advantages of assigning only one texture to a CSG object
  4508. instead of assigning the texture to each individual component. First, it is
  4509. much easier to use one texture if our CSG object has a lot of components
  4510. because changing the objects appearance involves changing only one single
  4511. texture. Second, the file parses faster because the texture has to be parsed
  4512. only once. This may be a great factor when doing large scenes or animations.
  4513. Third, using only one texture saves memory because the texture is only stored
  4514. once and referenced by all components of the CSG object. Assigning the
  4515. texture to all n components means that it is stored n times.
  4516.  
  4517. 4.5.3            CSG Intersection
  4518.  
  4519. Now let's use these same spheres to illustrate the next kind of CSG object,
  4520. the intersection. We change the word union to intersection and delete the
  4521. scale and rotate statements:
  4522.  
  4523.   intersection {
  4524.     sphere { <0, 0, 0>, 1
  4525.       translate -0.5*x
  4526.     }
  4527.     sphere { <0, 0, 0>, 1
  4528.       translate 0.5*x
  4529.     }
  4530.     pigment { Red }
  4531.   }
  4532.  
  4533.  
  4534. We trace the file and will see a lens-shaped object instead of the two
  4535. spheres. This is because an intersection consists of the area shared by both
  4536. shapes, in this case the lens-shaped area where the two spheres overlap. We
  4537. like this lens-shaped object so we will use it to demonstrate differences.
  4538.  
  4539. 4.5.4            CSG Difference
  4540.  
  4541. We rotate the lens-shaped intersection about the y-axis so that the broad
  4542. side is facing the camera.
  4543.  
  4544.   intersection{
  4545.     sphere { <0, 0, 0>, 1
  4546.       translate -0.5*x
  4547.     }
  4548.     sphere { <0, 0, 0>, 1
  4549.       translate 0.5*x
  4550.     }
  4551.     pigment { Red }
  4552.     rotate 90*y
  4553.   }
  4554.  
  4555.  
  4556. Let's create a cylinder and stick it right in the middle of the lens.
  4557.  
  4558.   cylinder { <0, 0, -1> <0, 0, 1>, .35
  4559.     pigment { Blue }
  4560.   }
  4561.  
  4562.  
  4563. We render the scene to see the position of the cylinder. We will place a
  4564. difference block around both the lens-shaped intersection and the cylinder
  4565. like this:
  4566.  
  4567.   difference {
  4568.     intersection {
  4569.       sphere { <0, 0, 0>, 1
  4570.         translate -0.5*x
  4571.       }
  4572.       sphere { <0, 0, 0>, 1
  4573.         translate 0.5*x
  4574.       }
  4575.       pigment { Red }
  4576.       rotate 90*y
  4577.     }
  4578.     cylinder { <0, 0, -1> <0, 0, 1>, .35
  4579.       pigment { Blue }
  4580.     }
  4581.   }
  4582.  
  4583.  
  4584. We render the file again and see the lens-shaped intersection with a neat
  4585. hole in the middle of it where the cylinder was. The cylinder has been
  4586. subtracted from the intersection. Note that the pigment of the cylinder
  4587. causes the surface of the hole to be colored blue. If we eliminate this
  4588. pigment the surface of the hole will be red.
  4589.  
  4590. OK, let's get a little wilder now. Let's declare our perforated lens object
  4591. to give it a name. Let's also eliminate all textures in the declared object
  4592. because we will want them to be in the final union instead.
  4593.  
  4594.   #declare Lens_With_Hole = difference {
  4595.     intersection {
  4596.       sphere { <0, 0, 0>, 1
  4597.         translate -0.5*x
  4598.       }
  4599.       sphere { <0, 0, 0>, 1
  4600.         translate 0.5*x
  4601.       }
  4602.       rotate 90*y
  4603.     }
  4604.     cylinder { <0, 0, -1> <0, 0, 1>, .35 }
  4605.   }
  4606.  
  4607.  
  4608. Let's use a union to build a complex shape composed of copies of this object.
  4609.  
  4610.  
  4611.   union {
  4612.     object { Lens_With_Hole translate <-.65, .65, 0> }
  4613.     object { Lens_With_Hole translate <.65, .65, 0> }
  4614.     object { Lens_With_Hole translate <-.65, -.65, 0> }
  4615.     object { Lens_With_Hole translate <.65, -.65, 0> }
  4616.     pigment { Red }
  4617.   }
  4618.  
  4619.  
  4620. We render the scene. An interesting object to be sure. But let's try
  4621. something more. Let's make it a partially-transparent object by adding some
  4622. filter to the pigment block.
  4623.  
  4624.   union {
  4625.     object { Lens_With_Hole translate <-.65, .65, 0> }
  4626.     object { Lens_With_Hole translate <.65, .65, 0> }
  4627.     object { Lens_With_Hole translate <-.65, -.65, 0> }
  4628.     object { Lens_With_Hole translate <.65, -.65, 0> }
  4629.     pigment { Red filter .5 }
  4630.   }
  4631.  
  4632.  
  4633. We render the file again. This looks pretty good... only... we can see parts
  4634. of each of the lens objects inside the union! This is not good.
  4635.  
  4636. 4.5.5            CSG Merge
  4637.  
  4638. This brings us to the fourth kind of CSG object, the merge. Merges are the
  4639. same as unions, but the geometry of the objects in the CSG that is inside the
  4640. merge is not traced. This should eliminate the problem with our object. Let's
  4641. try it.
  4642.  
  4643.   merge {
  4644.     object { Lens_With_Hole translate <-.65, .65, 0> }
  4645.     object { Lens_With_Hole translate <.65, .65, 0> }
  4646.     object { Lens_With_Hole translate <-.65, -.65, 0> }
  4647.     object { Lens_With_Hole translate <.65, -.65, 0> }
  4648.     pigment { Red filter .5 }
  4649.   }
  4650.  
  4651.  
  4652. 4.5.6            CSG Pitfalls
  4653.  
  4654.  
  4655. 4.5.6.1          Coincidence Surfaces
  4656.  
  4657. POV-Ray uses inside/outside tests to determine the points at which a ray
  4658. intersects a CSG object. A problem arises when the surfaces of two different
  4659. shapes coincide because there is no way (due to numerical problems) to tell
  4660. whether a point on the coincident surface belongs to one shape or the other.
  4661.  
  4662. Look at the following example where a cylinder is used to cut a hole in a
  4663. larger box.
  4664.  
  4665.   difference {
  4666.     box { -1, 1 pigment { Red } }
  4667.     cylinder { -z, z, 0.5 pigment { Green } }
  4668.   }
  4669.  
  4670.  
  4671. If we trace this object we see red speckles where the hole is supposed to be.
  4672. This is caused by the coincident surfaces of the cylinder and the box. One
  4673. time the cylinder's surface is hit first by a viewing ray, resulting in the
  4674. correct rendering of the hole, and another time the box is hit first, leading
  4675. to a wrong result where the hole vanishes and red speckles appear.
  4676.  
  4677. This problem can be avoided by increasing the size of the cylinder to get rid
  4678. of the coincidence surfaces. This is done by:
  4679.  
  4680.   difference {
  4681.     box { -1, 1 pigment { Red } }
  4682.     cylinder { -1.001*z, 1.001*z, 0.5 pigment { Green } }
  4683.   }
  4684.  
  4685.  
  4686. In general we have to make the subtracted object a little bit larger in a CSG
  4687. difference. We just have to look for coincident surfaces and increase the
  4688. subtracted object appropriately to get rid of those surfaces.
  4689.  
  4690. The same problem occurs in CSG intersections and is also avoided by scaling
  4691. some of the involved objects.
  4692.  
  4693. 4.6              The Light Source
  4694.  
  4695. In any ray-traced scene, the light needed to illuminate our objects and their
  4696. surfaces must come from a light source. There are many kinds of light sources
  4697. available in POV-Ray and careful use of the correct kind can yield very
  4698. impressive results. Let's take a moment to explore some of the different
  4699. kinds of light sources and their various parameters.
  4700.  
  4701. 4.6.1            The Ambient Light Source
  4702.  
  4703. The ambient light source is used to simulate the effect of inter-diffuse
  4704. reflection. If there wasn't inter-diffuse reflection all areas not directly
  4705. lit by a light source would be completely dark. POV-Ray uses the ambient
  4706. keyword to determine how much light coming from the ambient light source is
  4707. reflected by a surface.
  4708.  
  4709. By default the ambient light source, which emits its light everywhere and in
  4710. all directions, is pure white (rgb <1,1,1>). Changing its color can be used
  4711. to create interesting effects. First of all the overall light level of the
  4712. scene can be adjusted easily. Instead of changing all ambient values in every
  4713. finish only the ambient light source is modified. By assigning different
  4714. colors we can create nice effects like a moody reddish ambient lighting. For
  4715. more details about the ambient light source see "Ambient Light".
  4716.  
  4717. Below is an example of a red ambient light source.
  4718.  
  4719.   global_settings { ambient_light rgb<1, 0, 0> }
  4720.  
  4721.  
  4722. 4.6.2            The Pointlight Source
  4723.  
  4724. Pointlights are exactly what the name indicates. A pointlight has no size, is
  4725. invisible and illuminates everything in the scene equally no matter how far
  4726. away from the light source it may be (this behavior can be changed). This is
  4727. the simplest and most basic light source. There are only two important
  4728. parameters, location and color. Let's design a simple scene and place a
  4729. pointlight source in it.
  4730.  
  4731. We create a new file and name it litedemo.pov. We edit it as follows:
  4732.  
  4733.   #include "colors.inc"
  4734.   #include "textures.inc"
  4735.  
  4736.   camera {
  4737.     location  <-4, 3, -9>
  4738.     look_at   <0, 0, 0>
  4739.     angle 48
  4740.   }
  4741.  
  4742.  
  4743. We add the following simple objects:
  4744.  
  4745.   plane { y, -1
  4746.     texture {
  4747.       pigment {
  4748.         checker
  4749.         color rgb<0.5, 0, 0>
  4750.         color rgb<0, 0.5, 0.5>
  4751.       }
  4752.       finish {
  4753.         diffuse 0.4
  4754.         ambient 0.2
  4755.         phong 1
  4756.         phong_size 100
  4757.         reflection 0.25
  4758.       }
  4759.     }
  4760.   }
  4761.  
  4762.   torus { 1.5, 0.5
  4763.     texture { Brown_Agate }
  4764.     rotate <90, 160, 0>
  4765.     translate  <-1, 1, 3>
  4766.   }
  4767.  
  4768.   box { <-1, -1, -1>, <1, 1, 1>
  4769.     texture { DMFLightOak }
  4770.     translate  <2, 0, 2.3>
  4771.   }
  4772.  
  4773.   cone { <0,1,0>, 0, <0,0,0>, 1
  4774.     texture { PinkAlabaster }
  4775.     scale <1, 3, 1>
  4776.     translate  <-2, -1, -1>
  4777.   }
  4778.  
  4779.   sphere { <0,0,0>,1
  4780.     texture { Sapphire_Agate }
  4781.     translate  <1.5, 0, -2>
  4782.   }
  4783.  
  4784.  
  4785. Now we add a pointlight:
  4786.  
  4787.   light_source {
  4788.     <2, 10, -3>
  4789.     color White
  4790.   }
  4791.  
  4792.  
  4793. We render this at 200x150 -A and see that the objects are clearly visible
  4794. with sharp shadows. The sides of curved objects nearest the light source are
  4795. brightest in color with the areas that are facing away from the light source
  4796. being darkest. We also note that the checkered plane is illuminated evenly
  4797. all the way to the horizon. This allows us to see the plane, but it is not
  4798. very realistic.
  4799.  
  4800. 4.6.3            The Spotlight Source
  4801.  
  4802. Spotlights are a very useful type of light source. They can be used to add
  4803. highlights and illuminate features much as a photographer uses spots to do
  4804. the same thing. There are a few more parameters with spotlights than with
  4805. pointlights. These are radius, falloff, tightness and point_at. The radius
  4806. parameter is the angle of the fully illuminated cone. The falloff parameter
  4807. is the angle of the umbra cone where the light falls off to darkness. The
  4808. tightness is a parameter that determines the rate of the light falloff. The
  4809. point_at parameter is just what it says, the location where the spotlight is
  4810. pointing to. Let's change the light in our scene as follows:
  4811.  
  4812.   light_source {
  4813.     <0, 10, -3>
  4814.     color White
  4815.     spotlight
  4816.     radius 15
  4817.     falloff 20
  4818.     tightness 10
  4819.     point_at <0, 0, 0>
  4820.   }
  4821.  
  4822.  
  4823. We render this at 200x150 -A and see that only the objects are illuminated.
  4824. The rest of the plane and the outer portions of the objects are now unlit.
  4825. There is a broad falloff area but the shadows are still razor sharp. Let's
  4826. try fiddling with some of these parameters to see what they do. We change the
  4827. falloff value to 16 (it must always be larger than the radius value) and
  4828. render again. Now the falloff is very narrow and the objects are either
  4829. brightly lit or in total darkness. Now we change falloff back to 20 and
  4830. change the tightness value to 100 (higher is tighter) and render again. The
  4831. spotlight appears to have gotten much smaller but what has really happened is
  4832. that the falloff has become so steep that the radius actually appears
  4833. smaller.
  4834.  
  4835. We decide that a tightness value of 10 (the default) and a falloff value of
  4836. 18 are best for this spotlight and we now want to put a few spots around the
  4837. scene for effect. Let's place a slightly narrower blue and a red one in
  4838. addition to the white one we already have:
  4839.  
  4840.   light_source {
  4841.     <10, 10, -1>
  4842.     color Red
  4843.     spotlight
  4844.     radius 12
  4845.     falloff 14
  4846.     tightness 10
  4847.     point_at <2, 0, 0>
  4848.   }
  4849.  
  4850.   light_source {
  4851.     <-12, 10, -1>
  4852.     color Blue
  4853.     spotlight
  4854.     radius 12
  4855.     falloff 14
  4856.     tightness 10
  4857.     point_at <-2, 0, 0>
  4858.   }
  4859.  
  4860.  
  4861. Rendering this we see that the scene now has a wonderfully mysterious air to
  4862. it. The three spotlights all converge on the objects making them blue on one
  4863. side and red on the other with enough white in the middle to provide a
  4864. balance.
  4865.  
  4866. 4.6.4            The Cylindrical Light Source
  4867.  
  4868. Spotlights are cone shaped, meaning that their effect will change with
  4869. distance. The farther away from the spotlight an object is, the larger the
  4870. apparent radius will be. But we may want the radius and falloff to be a
  4871. particular size no matter how far away the spotlight is. For this reason,
  4872. cylindrical light sources are needed. A cylindrical light source is just like
  4873. a spotlight, except that the radius and falloff regions are the same no
  4874. matter how far from the light source our object is. The shape is therefore a
  4875. cylinder rather than a cone. We can specify a cylindrical light source by
  4876. replacing the spotlight keyword with the cylinder keyword. We try this now
  4877. with our scene by replacing all three spotlights with cylinder lights and
  4878. rendering again. We see that the scene is much dimmer. This is because the
  4879. cylindrical constraints do not let the light spread out like in a spotlight.
  4880. Larger radius and falloff values are needed to do the job. We try a radius of
  4881. 20 and a falloff of 30 for all three lights. That's the ticket!
  4882.  
  4883. 4.6.5            The Area Light Source
  4884.  
  4885. So far all of our light sources have one thing in common. They produce sharp
  4886. shadows. This is because the actual light source is a point that is
  4887. infinitely small. Objects are either in direct sight of the light, in which
  4888. case they are fully illuminated, or they are not, in which case they are
  4889. fully shaded. In real life, this kind of stark light and shadow situation
  4890. exists only in outer space where the direct light of the sun pierces the
  4891. total blackness of space. But here on Earth, light bends around objects,
  4892. bounces off objects, and usually the source has some dimension, meaning that
  4893. it can be partially hidden from sight (shadows are not sharp anymore). They
  4894. have what is known as an umbra, or an area of fuzziness where there is
  4895. neither total light or shade. In order to simulate these soft shadows, a
  4896. ray-tracer must give its light sources dimension. POV-Ray accomplishes this
  4897. with a feature known as an area light.
  4898.  
  4899. Area lights have dimension in two axis'. These are specified by the first two
  4900. vectors in the area light syntax. We must also specify how many lights are to
  4901. be in the array. More will give us cleaner soft shadows but will take longer
  4902. to render. Usually a 3*3 or a 5*5 array will suffice. We also have the option
  4903. of specifying an adaptive value. The adaptive keyword tells the ray-tracer
  4904. that it can adapt to the situation and send only the needed rays to determine
  4905. the value of the pixel. If adaptive is not used, a separate ray will be sent
  4906. for every light in the area light. This can really slow things down. The
  4907. higher the adaptive value the cleaner the umbra will be but the longer the
  4908. trace will take. Usually an adaptive value of 1 is sufficient. Finally, we
  4909. probably should use the jitter keyword. This tells the ray-tracer to slightly
  4910. move the position of each light in the area light so that the shadows appear
  4911. truly soft instead of giving us an umbra consisting of closely banded
  4912. shadows.
  4913.  
  4914. OK, let's try one. We comment out the cylinder lights and add the following:
  4915.  
  4916.   light_source {
  4917.     <2, 10, -3>
  4918.     color White
  4919.     area_light <5, 0, 0>, <0, 0, 5>, 5, 5
  4920.     adaptive 1
  4921.     jitter
  4922.   }
  4923.  
  4924.  
  4925. This is a white area light centered at <2,10,-3>. It is 5 units (along the
  4926. x-axis) by 5 units (along the z-axis) in size and has 25 (5*5) lights in it.
  4927. We have specified adaptive 1 and jitter. We render this at 200x150 -A.
  4928.  
  4929. Right away we notice two things. The trace takes quite a bit longer than it
  4930. did with a point or a spotlight and the shadows are no longer sharp! They all
  4931. have nice soft umbrae around them. Wait, it gets better.
  4932.  
  4933. Spotlights and cylinder lights can be area lights too! Remember those sharp
  4934. shadows from the spotlights in our scene? It would not make much sense to use
  4935. a 5*5 array for a spotlight, but a smaller array might do a good job of
  4936. giving us just the right amount of umbra for a spotlight. Let's try it. We
  4937. comment out the area light and change the cylinder lights so that they read
  4938. as follows:
  4939.  
  4940.   light_source {
  4941.     <2, 10, -3>
  4942.     color White
  4943.     spotlight
  4944.     radius 15
  4945.     falloff 18
  4946.     tightness 10
  4947.     area_light <1, 0, 0>, <0, 0, 1>, 2, 2
  4948.     adaptive 1
  4949.     jitter
  4950.     point_at <0, 0, 0>
  4951.   }
  4952.  
  4953.   light_source {
  4954.     <10, 10, -1>
  4955.     color Red
  4956.     spotlight
  4957.     radius 12
  4958.     falloff 14
  4959.     tightness 10
  4960.     area_light <1, 0, 0>, <0, 0, 1>, 2, 2
  4961.     adaptive 1
  4962.     jitter
  4963.     point_at <2, 0, 0>
  4964.   }
  4965.  
  4966.   light_source {
  4967.     <-12, 10, -1>
  4968.     color Blue
  4969.     spotlight
  4970.     radius 12
  4971.     falloff 14
  4972.     tightness 10
  4973.     area_light <1, 0, 0>, <0, 0, 1>, 2, 2
  4974.     adaptive 1
  4975.     jitter
  4976.     point_at <-2, 0, 0>
  4977.   }
  4978.  
  4979.  
  4980. We now have three area-spotlights, one unit square consisting of an array of
  4981. four (2*2) lights, three different colors, all shining on our scene. We
  4982. render this at 200x150 -A. It appears to work perfectly. All our shadows have
  4983. small, tight umbrae, just the sort we would expect to find on an object under
  4984. a real spotlight.
  4985.  
  4986. 4.6.6            Assigning an Object to a Light Source
  4987.  
  4988. Light sources are invisible. They are just a location where the light appears
  4989. to be coming from. They have no true size or shape. If we want our light
  4990. source to be a visible shape, we can use the looks_like keyword. We can
  4991. specify that our light source can look like any object we choose. When we use
  4992. looks_like, no_shadow is applied to the object automatically. This is done so
  4993. that the object will not block any illumination from the light source. If we
  4994. want some blocking to occur (as in a lampshade), it is better to simply use a
  4995. union to do the same thing. Let's add such an object to our scene. Here is a
  4996. light bulb we have made just for this purpose:
  4997.  
  4998.   #declare Lightbulb = union {
  4999.     merge {
  5000.       sphere { <0,0,0>,1 }
  5001.       cylinder { <0,0,1>, <0,0,0>, 1
  5002.         scale <0.35, 0.35, 1.0>
  5003.         translate  0.5*z
  5004.       }
  5005.       texture {
  5006.         pigment {color rgb <1, 1, 1>}
  5007.         finish {ambient .8 diffuse .6}
  5008.       }
  5009.     }
  5010.     cylinder { <0,0,1>, <0,0,0>, 1
  5011.       scale <0.4, 0.4, 0.5>
  5012.       texture { Brass_Texture }
  5013.       translate  1.5*z
  5014.     }
  5015.     rotate -90*x
  5016.     scale .5
  5017.   }
  5018.  
  5019.  
  5020. Now we add the light source:
  5021.  
  5022.   light_source {
  5023.     <0, 2, 0>
  5024.     color White
  5025.     looks_like { Lightbulb }
  5026.   }
  5027.  
  5028.  
  5029. Rendering this we see that a fairly believable light bulb now illuminates the
  5030. scene. However, if we do not specify a high ambient value, the light bulb is
  5031. not lit by the light source. On the plus side, all of the shadows fall away
  5032. from the light bulb, just as they would in a real situation. The shadows are
  5033. sharp, so let's make our bulb an area light:
  5034.  
  5035.   light_source {
  5036.     <0, 2, 0>
  5037.     color White
  5038.     area_light <1, 0, 0>, <0, 1, 0>, 2, 2
  5039.     adaptive 1
  5040.     jitter
  5041.     looks_like { Lightbulb }
  5042.   }
  5043.  
  5044.  
  5045. We note that we have placed this area light in the x-y-plane instead of the
  5046. x-z-plane. We also note that the actual appearance of the light bulb is not
  5047. affected in any way by the light source. The bulb must be illuminated by some
  5048. other light source or by, as in this case, a high ambient value. More
  5049. interesting results might therefore be obtained in this case by using halos
  5050. (see section "Halos").
  5051.  
  5052. 4.6.7            Light Source Specials
  5053.  
  5054.  
  5055. 4.6.7.1          Using Shadowless Lights
  5056.  
  5057. Light sources can be assigned the shadowless keyword and no shadows will be
  5058. cast due to its presence in a scene. Sometimes, scenes are difficult to
  5059. illuminate properly using the lights we have chosen to illuminate our
  5060. objects. It is impractical and unrealistic to apply a higher ambient value to
  5061. the texture of every object in the scene. So instead, we would place a couple
  5062. of fill lights around the scene. Fill lights are simply dimmer lights with
  5063. the shadowless keyword that act to boost the illumination of other areas of
  5064. the scene that may not be lit well. Let's try using one in our scene.
  5065.  
  5066. Remember the three colored area spotlights? We go back and un-comment them
  5067. and comment out any other lights we have made. Now we add the following:   li
  5068.     <0, 20, 0>
  5069.     color Gray50
  5070.     shadowless
  5071.   }
  5072.  
  5073.  
  5074. This is a fairly dim light 20 units over the center of the scene. It will
  5075. give a dim illumination to all objects including the plane in the background.
  5076. We render it and see.
  5077.  
  5078. 4.6.7.2          Using Light Fading
  5079.  
  5080. If it is realism we want, it is not realistic for the plane to be evenly
  5081. illuminated off into the distance. In real life, light gets scattered as it
  5082. travels so it diminishes its ability to illuminate objects the farther it
  5083. gets from its source. To simulate this, POV-Ray allows us to use two
  5084. keywords: fade_distance, which specifies the distance at which full
  5085. illumination is achieved, and fade_power, an exponential value which
  5086. determines the actual rate of attenuation. Let's apply these keywords to our
  5087. fill light.
  5088.  
  5089. First, we make the fill light a little brighter by changing Gray50 to Gray75.
  5090. Now we change that fill light as follows:
  5091.  
  5092.   light_source {
  5093.     <0, 20, 0>
  5094.     color Gray75
  5095.     fade_distance 5
  5096.     fade_power 1
  5097.     shadowless
  5098.   }
  5099.  
  5100.  
  5101. This means that the full value of the fill light will be achieved at a
  5102. distance of 5 units away from the light source. The fade power of 1 means
  5103. that the falloff will be linear (the light falls of at a constant rate). We
  5104. render this to see the result.
  5105.  
  5106. That definitely worked! Now let's try a fade power of 2 and a fade distance
  5107. of 10. Again, this works well. The falloff is much faster with a fade power
  5108. of 2 so we had to raise the fade distance to 10.
  5109.  
  5110. 4.6.7.3          Light Sources and Atmosphere
  5111.  
  5112. By definition more than default, light sources are affected by atmosphere,
  5113. i.e. their light is scattered by the atmosphere. This can be turned off by
  5114. adding atmosphere off to the light source block. The light emitted by a light
  5115. source can also be attenuated by the atmosphere (and also fog), that is it
  5116. will be diminished as it travels through it, by adding
  5117. atmospheric_attenuation on. The falloff is exponential and depends on the
  5118. distance parameter of the atmosphere (or fog). We note that this feature only
  5119. affects light coming directly from the light source. Reflected and refracted
  5120. light is ignored.
  5121.  
  5122. Let's experiment with these keywords. First we must add an atmosphere to our
  5123. scene:
  5124.  
  5125.   #include "atmos.inc"
  5126.  
  5127.   atmosphere { Atmosphere2 }
  5128.  
  5129.  
  5130. We comment out the three lines that turn each of the three spotlights into
  5131. area lights. Otherwise the trace will take to long.
  5132.  
  5133.   //area_light <1, 0, 0>, <0, 0, 1>, 2, 2
  5134.   //adaptive 1
  5135.   //jitter
  5136.  
  5137.  
  5138. Tracing the scene at 200x150 -A we see that indeed the spotlights are
  5139. visible. We can see where the blue and red spots cross each other and where
  5140. the white overhead light shines down through the center of the scene. We also
  5141. notice that the spotlights appear to diminish in their intensity as the light
  5142. descends from the light source to the objects. The red light is all but gone
  5143. in the lower left part of the scene and the blue light all but gone in the
  5144. lower right. This is due to the atmospheric attenuation and lends a further
  5145. realism to the scene. The atmosphere-light source interaction gives our scene
  5146. a smoky, mysterious appearance, but the trace took a long time. Making those
  5147. spotlights area lights and it will take even longer. This is an inevitable
  5148. trade-off - tracing speed for image quality.
  5149.  
  5150. 4.7              Simple Texture Options
  5151.  
  5152. The pictures rendered so far where somewhat boring regarding the appearance
  5153. of the objects. Let's add some fancy features to the texture.
  5154.  
  5155. 4.7.1            Surface Finishes
  5156.  
  5157. One of the main features of a ray-tracer is its ability to do interesting
  5158. things with surface finishes such as highlights and reflection. Let's add a
  5159. nice little Phong highlight (shiny spot) to the sphere. To do this we need to
  5160. add a finish keyword followed by a parameter. We change the definition of the
  5161. sphere to this:
  5162.  
  5163.   sphere { <0, 1, 2>, 2
  5164.     texture {
  5165.       pigment { color Yellow } // Yellow is pre-defined in COLORS.INC
  5166.       finish { phong 1 }
  5167.     }
  5168.   }
  5169.  
  5170.  
  5171. We render the scene. The phong keyword adds a highlight the same color of the
  5172. light shining on the object. It adds a lot of credibility to the picture and
  5173. makes the object look smooth and shiny. Lower values of phong will make the
  5174. highlight less bright (values should be between 0 and 1).
  5175.  
  5176. 4.7.2            Adding Bumpiness
  5177.  
  5178. The highlight we have added illustrates how much of our perception depends on
  5179. the reflective properties of an object. Ray-tracing can exploit this by
  5180. playing tricks on our perception to make us see complex details that aren't
  5181. really there.
  5182.  
  5183. Suppose we wanted a very bumpy surface on the object. It would be very
  5184. difficult to mathematically model lots of bumps. We can however simulate the
  5185. way bumps look by altering the way light reflects off of the surface.
  5186. Reflection calculations depend on a vector called surface normal. This is a
  5187. vector which points away from the surface and is perpendicular to it. By
  5188. artificially modifying (or perturbing) this normal vector we can simulate
  5189. bumps. We change the scene to read as follows and render it:
  5190.  
  5191.   sphere { <0, 1, 2>, 2
  5192.     texture {
  5193.       pigment { color Yellow }
  5194.       normal { bumps 0.4 scale 0.2 }
  5195.       finish { phong 1}
  5196.     }
  5197.   }
  5198.  
  5199.  
  5200. This tells POV-Ray to use a bump pattern to modify the surface normal. The
  5201. value 0.4 controls the apparent depth of the bumps. Usually the bumps are
  5202. about 1 unit wide which doesn't work very well with a sphere of radius 2. The
  5203. scale makes the bumps 1/5th as wide but does not affect their depth.
  5204.  
  5205. 4.7.3            Creating Color Patterns
  5206.  
  5207. We can do more than assigning a solid color to an object. We can create
  5208. complex patterns in the pigment block like in this example:
  5209.  
  5210.   sphere { <0, 1, 2>, 2
  5211.     texture {
  5212.       pigment {
  5213.         wood
  5214.         color_map {
  5215.           [0.0 color DarkTan]
  5216.           [0.9 color DarkBrown]
  5217.           [1.0 color VeryDarkBrown]
  5218.         }
  5219.         turbulence 0.05
  5220.         scale <0.2, 0.3, 1>
  5221.       }
  5222.       finish { phong 1 }
  5223.     }
  5224.   }
  5225.  
  5226.  
  5227. The keyword wood specifies a pigment pattern of concentric rings like rings
  5228. in wood. The color_map keyword specifies that the color of the wood should
  5229. blend from DarkTan to DarkBrown over the first 90% of the vein and from
  5230. DarkBrown to VeryDarkBrown over the remaining 10%. The turbulence keyword
  5231. slightly stirs up the pattern so the veins aren't perfect circles and the
  5232. scale keyword adjusts the size of the pattern.
  5233.  
  5234. Most patterns are set up by default to give us one feature across a sphere of
  5235. radius 1.0. A feature is very roughly defined as a color transition. For
  5236. example, a wood texture would have one band on a sphere of radius 1.0. In
  5237. this example we scale the pattern using the scale keyword followed by a
  5238. vector. In this case we scaled 0.2 in the x direction, 0.3 in the y direction
  5239. and the z direction is scaled by 1, which leaves it unchanged. Scale values
  5240. larger than one will stretch an element. Scale values smaller than one will
  5241. squish an element. A scale value of one will leave an element unchanged.
  5242.  
  5243. 4.7.4            Pre-defined Textures
  5244.  
  5245. POV-Ray has some very sophisticated textures pre-defined in the standard
  5246. include files glass.inc, metals.inc, stones.inc and woods.inc. Some are
  5247. entire textures with pigment, normal and/or finish parameters already
  5248. defined. Some are just pigments or just finishes. We change the definition of
  5249. our sphere to the following and then re-render it:
  5250.  
  5251.   sphere { <0, 1, 2>, 2
  5252.     texture {
  5253.       pigment {
  5254.         DMFWood4       // pre-defined in textures.inc
  5255.         scale 4        // scale by the same amount in all
  5256.                        // directions
  5257.       }
  5258.       finish { Shiny } // pre-defined in finish.inc
  5259.     }
  5260.   }
  5261.  
  5262.  
  5263. The pigment identifier DMFWood4 has already been scaled down quite small when
  5264. it was defined. For this example we want to scale the pattern larger. Because
  5265. we want to scale it uniformly we can put a single value after the scale
  5266. keyword rather than a vector of x, y, z scale factors.
  5267.  
  5268. We look through the file textures.inc to see what pigments and finishes are
  5269. defined and try them out. We just insert the name of the new pigment where
  5270. DMFWood4 is now or try a different finish in place of Shiny and re-render our
  5271. file.
  5272.  
  5273. Here is an example of using a complete texture identifier rather than just
  5274. the pieces.
  5275.  
  5276.   sphere { <0, 1, 2>, 2
  5277.     texture { PinkAlabaster }
  5278.   }
  5279.  
  5280.  
  5281. 4.8              Advanced Texture Options
  5282.  
  5283. The extremely powerful texturing ability is one thing that really sets
  5284. POV-Ray apart from other raytracers. So far we have not really tried anything
  5285. too complex but by now we should be comfortable enough with the program's
  5286. syntax to try some of the more advanced texture options.
  5287.  
  5288. Obviously, we cannot try them all. It would take a tutorial a lot more pages
  5289. to use every texturing option available in POV-Ray. For this limited
  5290. tutorial, we will content ourselves to just trying a few of them to give an
  5291. idea of how textures are created. With a little practice, we will soon be
  5292. creating beautiful textures of our own.
  5293.  
  5294. 4.8.1            Pigment and Normal Patterns
  5295.  
  5296. Previous versions of POV-Ray made a distinction between pigment and normal
  5297. patterns, i. e. patterns that could be used inside a normal or pigment
  5298. statement. With POV-Ray 3.0 this restriction was removed so that all patterns
  5299. listed in section "Patterns" can be used as a pigment or normal pattern.
  5300.  
  5301. 4.8.2            Pigments
  5302.  
  5303. Every surface must have a color. In POV-Ray this color is called a pigment.
  5304. It does not have to be a single color. It can be a color pattern, a color
  5305. list or even an image map. Pigments can also be layered one on top of the
  5306. next so long as the uppermost layers are at least partially transparent so
  5307. the ones beneath can show through. Let's play around with some of these kinds
  5308. of pigments.
  5309.  
  5310. We create a file called texdemo.pov and edit it as follows:
  5311.  
  5312.   #include "colors.inc"
  5313.  
  5314.   camera {
  5315.     location <1, 1, -7>
  5316.     look_at 0
  5317.     angle 36
  5318.   }
  5319.  
  5320.   light_source { <1000, 1000, -1000> White }
  5321.  
  5322.   plane { y, -1.5
  5323.     pigment { checker Green, White }
  5324.   }
  5325.  
  5326.   sphere { <0,0,0>, 1
  5327.     pigment { Red }
  5328.   }
  5329.  
  5330.  
  5331. Giving this file a quick test render at 200x150 -A we see that it is a simple
  5332. red sphere against a green and white checkered plane. We will be using the
  5333. sphere for our textures.
  5334.  
  5335. 4.8.2.1          Using Color List Pigments
  5336.  
  5337. Before we begin we should note that we have already made one kind of pigment,
  5338. the color list pigment. In the previous example we have used a checkered
  5339. pattern on our plane. There are two other kinds of color list pigments, brick
  5340. and hexagon. Let's quickly try each of these. First, we change the plane's
  5341. pigment as follows:
  5342.  
  5343.   pigment { hexagon Green, White, Yellow }
  5344.  
  5345.  
  5346. Rendering this we see a three-color hexagonal pattern. Note that this pattern
  5347. requires three colors. Now we change the pigment to...
  5348.  
  5349.   pigment { brick Gray75, Red rotate -90*x scale .25 }
  5350.  
  5351.  
  5352. Looking at the resulting image we see that the plane now has a brick pattern.
  5353. We note that we had to rotate the pattern to make it appear correctly on the
  5354. flat plane. This pattern normally is meant to be used on vertical surfaces.
  5355. We also had to scale the pattern down a bit so we could see it more easily.
  5356. We can play around with these color list pigments, change the colors, etc.
  5357. until we get a floor that we like.
  5358.  
  5359. 4.8.2.2          Using Pigment and Patterns
  5360.  
  5361. Let's begin texturing our sphere by using a pattern and a color map
  5362. consisting of three colors. wE replace the pigment block with the following.
  5363.  
  5364.   pigment {
  5365.     gradient x
  5366.     color_map {
  5367.       [0.00 color Red]
  5368.       [0.33 color Blue]
  5369.       [0.66 color Yellow]
  5370.       [1.00 color Red]
  5371.     }
  5372.   }
  5373.  
  5374.  
  5375. Rendering this we see that it gives us an interesting pattern of vertical
  5376. stripes. We change the gradient direction to y. The stripes are horizontal
  5377. now. We change the gradient direction to z. The stripes are now more like
  5378. concentric rings. This is because the gradient direction is directly away
  5379. from the camera. We change the direction back to x and add the following to
  5380. the pigment block.
  5381.  
  5382.   pigment {
  5383.     gradient x
  5384.     color_map {
  5385.       [0.00 color Red]
  5386.       [0.33 color Blue]
  5387.       [0.66 color Yellow]
  5388.       [1.00 color Red]
  5389.     }
  5390.     rotate -45*z          // <- add this line
  5391.   }
  5392.  
  5393.  
  5394. The vertical bars are now slanted at a 45 degree angle. All patterns can be
  5395. rotated, scaled and translated in this manner. Let's now try some different
  5396. types of patterns. One at a time, we substitute the following keywords for
  5397. gradient x and render to see the result: bozo, marble, agate, granite,
  5398. leopard, spotted and wood (if we like we can test all patterns listed in
  5399. section "Patterns").
  5400.  
  5401. Rendering these we see that each results in a slightly different pattern. But
  5402. to get really good results each type of pattern requires the use of some
  5403. pattern modifiers.
  5404.  
  5405. 4.8.2.3          Using Pattern Modifiers
  5406.  
  5407. Let's take a look at some pattern modifiers. First, we change the pattern
  5408. type to bozo. Then we add the following change.
  5409.  
  5410.   pigment {
  5411.     bozo
  5412.     frequency 3            // <- add this line
  5413.     color_map {
  5414.       [0.00 color Red]
  5415.       [0.33 color Blue]
  5416.       [0.66 color Yellow]
  5417.       [1.00 color Red]
  5418.     }
  5419.     rotate -45*z
  5420.   }
  5421.  
  5422.  
  5423. The frequency modifier determines the number of times the color map repeats
  5424. itself per unit of size. This change makes the bozo pattern we saw earlier
  5425. have many more bands in it. Now we change the pattern type to marble. When we
  5426. rendered this earlier, we saw a banded pattern similar to gradient y that
  5427. really did not look much like marble at all. This is because marble really is
  5428. a kind of gradient and it needs another pattern modifier to look like marble.
  5429. This modifier is called turbulence. We change the line frequency 3 to
  5430. turbulence 1 and render again. That's better! Now let's put frequency 3 back
  5431. in right after the turbulence and take another look. Even more interesting!
  5432.  
  5433. But wait, it get's better! Turbulence itself has some modifiers of its own.
  5434. We can adjust the turbulence several ways. First, the float that follows the
  5435. turbulence keyword can be any value with higher values giving us more
  5436. turbulence. Second, we can use the keywords omega, lambda and octaves to
  5437. change the turbulence parameters. Let's try this now:
  5438.  
  5439.   pigment {
  5440.     marble
  5441.     turbulence 0.5
  5442.     lambda 1.5
  5443.     omega 0.8
  5444.     octaves 5
  5445.     frequency 3
  5446.     color_map {
  5447.       [0.00 color Red]
  5448.       [0.33 color Blue]
  5449.       [0.66 color Yellow]
  5450.       [1.00 color Red]
  5451.     }
  5452.     rotate 45*z
  5453.   }
  5454.  
  5455.  
  5456. Rendering this we see that the turbulence has changed and the pattern looks
  5457. different. We play around with the numerical values of turbulence, lambda,
  5458. omega and octaves to see what they do.
  5459.  
  5460. 4.8.2.4          Using Transparent Pigments and Layered Textures
  5461.  
  5462. Pigments are described by numerical values that give the rgb value of the
  5463. color to be used (like color rgb <1, 0, 0> giving us a red color). But this
  5464. syntax will give us more than just the rgb values. We can specify filtering
  5465. transparency by changing it as follows: color rgbf<1, 0, 0, 1>. The f stands
  5466. for filter, POV-Ray's word for filtered transparency. A value of one means
  5467. that the color is completely transparent, but still filters the light
  5468. according to what the pigment is. In this case, the color will be a
  5469. transparent red, like red cellophane.
  5470.  
  5471. There is another kind of transparency in POV-Ray. It is called transmittance
  5472. or non-filtering transparency (the keyword is transmit). It is different from
  5473. filter in that it does not filter the light according to the pigment color.
  5474. It instead allows all the light to pass through unchanged. It can be
  5475. specified like this: rgbt <1, 0, 0, 1>.
  5476.  
  5477. Let's use some transparent pigments to create another kind of texture, the
  5478. layered texture. Returning to our previous example, declare the following
  5479. texture.
  5480.  
  5481.   #declare LandArea = texture {
  5482.       pigment {
  5483.         agate
  5484.         turbulence 1
  5485.         lambda 1.5
  5486.         omega .8
  5487.         octaves 8
  5488.         color_map {
  5489.           [0.00 color rgb <.5, .25, .15>]
  5490.           [0.33 color rgb <.1, .5, .4>]
  5491.           [0.86 color rgb <.6, .3, .1>]
  5492.           [1.00 color rgb <.5, .25, .15>]
  5493.         }
  5494.       }
  5495.     }
  5496.   }
  5497.  
  5498.  
  5499. This texture will be the land area. Now let's make the oceans by declaring
  5500. the following.
  5501.  
  5502.   #declare OceanArea = texture {
  5503.     pigment {
  5504.       bozo
  5505.         turbulence .5
  5506.         lambda 2
  5507.         color_map {
  5508.           [0.00, 0.33 color rgb <0, 0, 1>
  5509.                       color rgb <0, 0, 1>]
  5510.           [0.33, 0.66 color rgbf <1, 1, 1, 1>
  5511.                       color rgbf <1, 1, 1, 1>]
  5512.           [0.66, 1.00 color rgb <0, 0, 1>
  5513.                       color rgb <0, 0, 1>]
  5514.         }
  5515.       }
  5516.     }
  5517.   }
  5518.  
  5519.  
  5520. Note how the ocean is the opaque blue area and the land is the clear area
  5521. which will allow the underlying texture to show through.
  5522.  
  5523. Now, let's declare one more texture to simulate an atmosphere with swirling
  5524. clouds.
  5525.  
  5526.   #declare CloudArea = texture {
  5527.     pigment {
  5528.       agate
  5529.       turbulence 1
  5530.       lambda 2
  5531.       frequency 2
  5532.       color_map {
  5533.         [0.0 color rgbf <1, 1, 1, 1>]
  5534.         [0.5 color rgbf <1, 1, 1, .35>]
  5535.         [1.0 color rgbf <1, 1, 1, 1>]
  5536.       }
  5537.     }
  5538.   }
  5539.  
  5540.  
  5541. Now apply all of these to our sphere.
  5542.  
  5543.   sphere { <0,0,0>, 1
  5544.     texture { LandArea }
  5545.     texture { OceanArea }
  5546.     texture { CloudArea }
  5547.   }
  5548.  
  5549.  
  5550. We render this and have a pretty good rendition of a little planetoid. But it
  5551. could be better. We don't particularly like the appearance of the clouds.
  5552. There is a way they could be done that would be much more realistic.
  5553.  
  5554. 4.8.2.5          Using Pigment Maps
  5555.  
  5556. Pigments may be blended together in the same way as the colors in a color map
  5557. using the same pattern keywords that we can use for pigments. Let's just give
  5558. it a try.
  5559.  
  5560. We add the following declarations, making sure they appear before the other
  5561. declarations in the file.
  5562.  
  5563.   #declare Clouds1 = pigment {
  5564.       bozo
  5565.       turbulence 1
  5566.       color_map {
  5567.         [0.0 color White filter 1]
  5568.         [0.5 color White]
  5569.         [1.0 color White filter 1]
  5570.       }
  5571.     }
  5572.   #declare Clouds2 = pigment {
  5573.     agate
  5574.     turbulence 1
  5575.     color_map {
  5576.       [0.0 color White filter 1]
  5577.       [0.5 color White]
  5578.       [1.0 color White filter 1]
  5579.       }
  5580.     }
  5581.   #declare Clouds3 = pigment {
  5582.     marble
  5583.     turbulence 1
  5584.     color_map {
  5585.       [0.0 color White filter 1]
  5586.       [0.5 color White]
  5587.       [1.0 color White filter 1]
  5588.     }
  5589.   }
  5590.   #declare Clouds4 = pigment {
  5591.     granite
  5592.     turbulence 1
  5593.     color_map {
  5594.       [0.0 color White filter 1]
  5595.       [0.5 color White]
  5596.       [1.0 color White filter 1]
  5597.     }
  5598.   }
  5599.  
  5600.  
  5601. Now we use these declared pigments in our cloud layer on our planetoid. We
  5602. replace the declared cloud layer with.
  5603.  
  5604.   #declare CloudArea = texture {
  5605.     pigment {
  5606.       gradient y
  5607.       pigment_map {
  5608.         [0.00 Clouds1]
  5609.         [0.25 Clouds2]
  5610.         [0.50 Clouds3]
  5611.         [0.75 Clouds4]
  5612.         [1.00 Clouds1]
  5613.       }
  5614.     }
  5615.   }
  5616.  
  5617.  
  5618. We render this and see a remarkable pattern that looks very much like weather
  5619. patterns on the planet earth. They are separated into bands, simulating the
  5620. different weather types found at different latitudes.
  5621.  
  5622. 4.8.3            Normals
  5623.  
  5624. Objects in POV-Ray have very smooth surfaces. This is not very realistic so
  5625. there are several ways to disturb the smoothness of an object by perturbing
  5626. the surface normal. The surface normal is the vector that is perpendicular to
  5627. the angle of the surface. By changing this normal the surface can be made to
  5628. appear bumpy, wrinkled or any of the many patterns available. Let's try a
  5629. couple of them.
  5630.  
  5631. 4.8.3.1          Using Basic Normal Modifiers
  5632.  
  5633. We comment out the planetoid sphere for now and, at the bottom of the file,
  5634. create a new sphere with a simple, single color texture.
  5635.  
  5636.   sphere { <0,0,0>, 1
  5637.     pigment { Gray75 }
  5638.     normal { bumps 1 scale .2 }
  5639.   }
  5640.  
  5641.  
  5642. Here we have added a normal block in addition to the pigment block (note that
  5643. these do not have to be included in a texture block unless they need to be
  5644. transformed together or need to be part of a layered texture). We render this
  5645. to see what it looks like. Now, one at a time, we substitute for the keyword
  5646. bumps the following keywords: dents, wrinkles, ripples and waves (we can also
  5647. use any of the patterns listed in "Patterns"). We render each to see what
  5648. they look like. We play around with the float value that follows the keyword.
  5649. We also experiment with the scale value.
  5650.  
  5651. For added interest, we change the plane texture to a single color with a
  5652. normal as follows.
  5653.  
  5654.   plane { y, -1.5
  5655.     pigment { color rgb <.65, .45, .35> }
  5656.     normal { dents .75 scale .25 }
  5657.   }
  5658.  
  5659.  
  5660. 4.8.3.2          Blending Normals
  5661.  
  5662. Normals can be layered similar to pigments but the results can be unexpected.
  5663. Let's try that now by editing the sphere as follows.
  5664.  
  5665.   sphere { <0,0,0>, 1
  5666.     pigment { Gray75 }
  5667.       normal { radial frequency 10 }
  5668.       normal { gradient y scale .2 }
  5669.   }
  5670.  
  5671.  
  5672. As we can see, the resulting pattern is neither a radial nor a gradient. It
  5673. is instead the result of first calculating a radial pattern and then
  5674. calculating a gradient pattern. The results are simply additive. This can be
  5675. difficult to control so POV-Ray gives the user other ways to blend normals.
  5676.  
  5677. One way is to use normal maps. A normal map works the same way as the pigment
  5678. map we used earlier. Let's change our sphere texture as follows.
  5679.  
  5680.   sphere { <0,0,0>, 1
  5681.     pigment { Gray75 }
  5682.     normal {
  5683.       gradient y
  5684.       frequency 3
  5685.       turbulence .5
  5686.       normal_map {
  5687.         [0.00 granite]
  5688.         [0.25 spotted turbulence .35]
  5689.         [0.50 marble turbulence .5]
  5690.         [0.75 bozo turbulence .25]
  5691.         [1.00 granite]
  5692.       }
  5693.     }
  5694.   }
  5695.  
  5696.  
  5697. Rendering this we see that the sphere now has a very irregular bumpy surface.
  5698. The gradient pattern type separates the normals into bands but they are
  5699. turbulated, giving the surface a chaotic appearance. But this give us an
  5700. idea.
  5701.  
  5702. Suppose we use the same pattern for a normal map that we used to create the
  5703. oceans on our planetoid and applied it to the land areas. Does it follow that
  5704. if we use the same pattern and modifiers on a sphere the same size that the
  5705. shape of the pattern would be the same? Wouldn't that make the land areas
  5706. bumpy while leaving the oceans smooth? Let's try it. First, let's render the
  5707. two spheres side-by-side so we can see if the pattern is indeed the same. We
  5708. un-comment the planetoid sphere and make the following changes.
  5709.  
  5710.   sphere { <0,0,0>, 1
  5711.     texture { LandArea }
  5712.     texture { OceanArea }
  5713.     //texture { CloudArea }  // <-comment this out
  5714.     translate -x             // <- add this transformation
  5715.   }
  5716.  
  5717.  
  5718. Now we change the gray sphere as follows.
  5719.  
  5720.   sphere { <0,0,0>, 1
  5721.     pigment { Gray75 }
  5722.     normal {
  5723.       bozo
  5724.       turbulence .5
  5725.       lambda 2
  5726.       normal_map {
  5727.         [0.4 dents .15 scale .01]
  5728.         [0.6 agate turbulence 1]
  5729.         [1.0 dents .15 scale .01]
  5730.       }
  5731.     }
  5732.     translate x // <- add this transformation
  5733.   }
  5734.  
  5735.  
  5736. We render this to see if the pattern is the same. We see that indeed it is.
  5737. So let's comment out the gray sphere and add the normal block it contains to
  5738. the land area texture of our planetoid. We remove the transformations so that
  5739. the planetoid is centered in the scene again.
  5740.  
  5741.   #declare LandArea = texture {
  5742.     pigment {
  5743.       agate
  5744.       turbulence 1
  5745.       lambda 1.5
  5746.       omega .8
  5747.       octaves 8
  5748.       color_map {
  5749.         [0.00 color rgb <.5, .25, .15>]
  5750.         [0.33 color rgb <.1, .5, .4>]
  5751.         [0.86 color rgb <.6, .3, .1>]
  5752.         [1.00 color rgb <.5, .25, .15>]
  5753.       }
  5754.     }
  5755.     normal {
  5756.       bozo
  5757.       turbulence .5
  5758.       lambda 2
  5759.       normal_map {
  5760.         [0.4 dents .15 scale .01]
  5761.         [0.6 agate turbulence 1]
  5762.         [1.0 dents .15 scale .01]
  5763.       }
  5764.     }
  5765.   }
  5766.  
  5767.  
  5768. Looking at the resulting image we see that indeed our idea works! The land
  5769. areas are bumpy while the oceans are smooth. We add the cloud layer back in
  5770. and our planetoid is complete.
  5771.  
  5772. There is much more that we did not cover here due to space constraints. On
  5773. our own, we should take the time to explore slope maps, average and bump
  5774. maps.
  5775.  
  5776. 4.8.4            Finishes
  5777.  
  5778. The final part of a POV-Ray texture is the finish. It controls the properties
  5779. of the surface of an object. It can make it shiny and reflective, or dull and
  5780. flat. It can also specify what happens to light that passes through
  5781. transparent pigments, what happens to light that is scattered by
  5782. less-than-perfectly-smooth surfaces and what happens to light that is
  5783. reflected by surfaces with thin-film interference properties. There are
  5784. twelve different properties available in POV-Ray to specify the finish of a
  5785. given object. These are controlled by the following keywords: ambient,
  5786. diffuse, brilliance, phong, specular, metallic, reflection, refraction,
  5787. caustics, attenuation, crand and iridescence. Let's design a couple of
  5788. textures that make use of these parameters.
  5789.  
  5790. 4.8.4.1          Using Ambient
  5791.  
  5792. Since objects in POV-Ray are illuminated by light sources, the portions of
  5793. those objects that are in shadow would be completely black were it not for
  5794. the first two finish properties, ambient and diffuse. Ambient is used to
  5795. simulate the light that is scattered around the scene that does not come
  5796. directly from a light source. Diffuse determines how much of the light that
  5797. is seen comes directly from a light source. These two keywords work together
  5798. to control the simulation of ambient light. Let's use our gray sphere to
  5799. demonstrate this. Let's also change our plane back to its original green and
  5800. white checkered pattern.
  5801.  
  5802.   plane {y,-1.5
  5803.     pigment {checker Green, White}
  5804.   }
  5805.  
  5806.   sphere { <0,0,0>, 1
  5807.     pigment {Gray75}
  5808.     finish {
  5809.       ambient .2
  5810.       diffuse .6
  5811.   }
  5812.  
  5813.  
  5814. In the above example, the default values for ambient and diffuse are used. We
  5815. render this to see what the effect is and then make the following change to
  5816. the finish.
  5817.  
  5818.   ambient 0
  5819.   diffuse 0
  5820.  
  5821.  
  5822. The sphere is black because we have specified that none of the light coming
  5823. from any light source will be reflected by the sphere. Let's change diffuse
  5824. back to the default of 0.6.
  5825.  
  5826. Now we see the gray surface color where the light from the light source falls
  5827. directly on the sphere but the shaded side is still absolutely black. Now
  5828. let's change diffuse to 0.3 and ambient to 0.3.
  5829.  
  5830. The sphere now looks almost flat. This is because we have specified a fairly
  5831. high degree of ambient light and only a low amount of the light coming from
  5832. the light source is diffusely reflected towards the camera. The default
  5833. values of ambient and diffuse are pretty good averages and a good starting
  5834. point. In most cases, an ambient value of 0.1 ... 0.2 is sufficient and a
  5835. diffuse value of 0.5 ... 0.7 will usually do the job. There are a couple of
  5836. exceptions. If we have a completely transparent surface with high refractive
  5837. and/or reflective values, low values of both ambient and diffuse may be best.
  5838. Here is an example.
  5839.  
  5840.   sphere { <0,0,0>, 1
  5841.      pigment { White filter 1 }
  5842.        finish {
  5843.          ambient 0
  5844.          diffuse 0
  5845.          reflection .25
  5846.          refraction 1
  5847.          ior 1.33
  5848.          specular 1
  5849.          roughness .001
  5850.       }
  5851.     }
  5852.   }
  5853.  
  5854.  
  5855. This is glass, obviously. Glass is a material that takes nearly all of its
  5856. appearance from its surroundings. Very little of the surface is seen because
  5857. it transmits or reflects practically all of the light that shines on it. See
  5858. glass.inc for some other examples.
  5859.  
  5860. If we ever need an object to be completely illuminated independently of the
  5861. lighting situation in a given scene we can do this artificially by specifying
  5862. an ambient value of 1 and a diffuse value of 0. This will eliminate all
  5863. shading and simply give the object its fullest and brightest color value at
  5864. all points. This is good for simulating objects that emit light like
  5865. lightbulbs and for skies in scenes where the sky may not be adequately lit by
  5866. any other means.
  5867.  
  5868. Let's try this with our sphere now.
  5869.  
  5870.   sphere { <0,0,0>, 1
  5871.     pigment { White }
  5872.       finish {
  5873.         ambient 1
  5874.         diffuse 0
  5875.       }
  5876.     }
  5877.   }
  5878.  
  5879.  
  5880. Rendering this we get a blinding white sphere with no visible highlights or
  5881. shaded parts. It would make a pretty good streetlight.
  5882.  
  5883. 4.8.4.2          Using Surface Highlights
  5884.  
  5885. In the glass example above, we noticed that there were bright little hotspots
  5886. on the surface. This gave the sphere a hard, shiny appearance. POV-Ray gives
  5887. us two ways to specify surface specular highlights. The first is called Phong
  5888. highlighting. Usually, Phong highlights are described using two keywords:
  5889. phong and phong_size. The float that follows phong determines the brightness
  5890. of the highlight while the float following phong_size determines its size.
  5891. Let's try this.
  5892.  
  5893.   sphere { <0,0,0>, 1
  5894.     pigment { Gray50 }
  5895.     finish {
  5896.       ambient .2
  5897.       diffuse .6
  5898.       phong .75
  5899.       phong_size 25
  5900.     }
  5901.   }
  5902.  
  5903.  
  5904. Rendering this we see a fairly broad, soft highlight that gives the sphere a
  5905. kind of plastic appearance. Now let's change phong_size to 150. This makes a
  5906. much smaller highlight which gives the sphere the appearance of being much
  5907. harder and shinier.
  5908.  
  5909. There is another kind of highlight that is calculated by a different means
  5910. called specular highlighting. It is specified using the keyword specular and
  5911. operates in conjunction with another keyword called roughness. These two
  5912. keywords work together in much the same way as phong and phong_size to create
  5913. highlights that alter the apparent shininess of the surface. Let's try using
  5914. specular in our sphere.
  5915.  
  5916.   sphere { <0,0,0>, 1
  5917.     pigment { Gray50 }
  5918.       finish {
  5919.         ambient .2
  5920.         diffuse .6
  5921.         specular .75
  5922.         roughness .1
  5923.       }
  5924.     }
  5925.   }
  5926.  
  5927.  
  5928. Looking at the result we see a broad, soft highlight similar to what we had
  5929. when we used phong_size of 25. Change roughness to .001 and render again. Now
  5930. we see a small, tight highlight similar to what we had when we used
  5931. phong_size of 150. Generally speaking, specular is slightly more accurate and
  5932. therefore slightly more realistic than phong but you should try both methods
  5933. when designing a texture. There are even times when both phong and specular
  5934. may be used on a finish.
  5935.  
  5936. 4.8.4.3          Using Reflection and Metallic
  5937.  
  5938. There is another surface parameter that goes hand in hand with highlights,
  5939. reflection. Surfaces that are very shiny usually have a degree of reflection
  5940. to them. Let's take a look at an example.
  5941.  
  5942.   sphere { <0,0,0>, 1
  5943.     pigment { Gray50 }
  5944.       finish {
  5945.         ambient .2
  5946.         diffuse .6
  5947.         specular .75
  5948.         roughness .001
  5949.         reflection .5
  5950.       }
  5951.     }
  5952.   }
  5953.  
  5954.  
  5955. We see that our sphere now reflects the green and white checkered plane and
  5956. the black background but the gray color of the sphere seems out of place.
  5957. This is another time when a lower diffuse value is needed. Generally, the
  5958. higher reflection is the lower diffuse should be. We lower the diffuse value
  5959. to 0.3 and the ambient value to 0.1 and render again. That is much better.
  5960. Let's make our sphere as shiny as a polished gold ball bearing.
  5961.  
  5962.   sphere { <0,0,0>, 1
  5963.     pigment { BrightGold }
  5964.       finish {
  5965.         ambient .1
  5966.         diffuse .1
  5967.         specular 1
  5968.         roughness .001
  5969.         reflection .75
  5970.       }
  5971.     }
  5972.   }
  5973.  
  5974.  
  5975. That is very close but there is something wrong with the highlight. To make
  5976. the surface appear more like metal the keyword metallic is used. We add it
  5977. now to see the difference.
  5978.  
  5979.   sphere { <0,0,0>, 1
  5980.     pigment { BrightGold }
  5981.       finish {
  5982.         ambient .1
  5983.         diffuse .1
  5984.         specular 1
  5985.         roughness .001
  5986.         reflection .75
  5987.         metallic
  5988.       }
  5989.     }
  5990.   }
  5991.  
  5992.  
  5993. We see that the highlight has taken on the color of the surface rather than
  5994. the light source. This gives the surface a more metallic appearance.
  5995.  
  5996. 4.8.4.4          Using Refraction
  5997.  
  5998. Objects that are transparent allow light to pass through them. With some
  5999. substances, the light is bent as it travels from one substance into the other
  6000. because of the differing optical densities of the objects. This is called
  6001. refraction. Water and glass both bend light in this manner. To create water
  6002. or glass, POV-Ray gives us a way to specify refraction. This is done with the
  6003. keywords refraction and ior. The amount of light that passes through an
  6004. object is determined by the value of the filtering and/or transmittance
  6005. channel in the pigment. We should use the refraction value only to switch
  6006. refraction on or off using values of 1 or 0 respectively (or the boolean
  6007. values on and off). See section "Refraction" for a detailed explanation of
  6008. the reasons.
  6009.  
  6010. The degree of refraction, i. e. the amount of bending that occurs, is given
  6011. by the keyword ior, short for index of refraction. If we know the index of
  6012. refraction of the substance we are trying to create, we may just use that.
  6013. For instance, water is 1.33, glass is around 1.45 and diamond is 1.75. Let's
  6014. return to the example of a glass sphere we used earlier.
  6015.  
  6016.   sphere { <0,0,0>, 1
  6017.     pigment { White filter 1 }
  6018.       finish {
  6019.         ambient 0
  6020.         diffuse 0
  6021.         reflection .25
  6022.         refraction 1
  6023.         ior 1.45
  6024.         specular 1
  6025.         roughness .001
  6026.       }
  6027.     }
  6028.   }
  6029.  
  6030.  
  6031. We render this again and notice how the plane that is visible through the
  6032. sphere is distorted and turned upside-down. This is because the light passing
  6033. through the sphere is being bent or refracted to the degree specified. We
  6034. reduce ior to 1.25 and re-render. We increase it to 1.75 and re-render. We
  6035. notice how the distortion changes.
  6036.  
  6037. 4.8.4.5          Adding Light Attenuation
  6038.  
  6039. Transparent objects can be made to cause the intensity of light passing
  6040. through them to be reduced. In reality, this is due to impurities in
  6041. scattering the light. Two float values determine the effect: fade_distance is
  6042. the distance the light has to travel to reach one-half its original intensity
  6043. and fade_power is the degree of falloff. Let's try an example of this.
  6044.  
  6045.   sphere { <0,0,0>, 1
  6046.     pigment { White filter 1 }
  6047.       finish {
  6048.         ambient .1
  6049.         diffuse .1
  6050.         reflection .15
  6051.         refraction 1
  6052.         ior 1.45
  6053.         specular 1
  6054.         roughness .001
  6055.         fade_distance 5
  6056.         fade_power 1
  6057.     }
  6058.   }
  6059.  
  6060.  
  6061. The caustics of a translucent sphere.
  6062.  
  6063. This gives the sphere a slightly clouded look as if not all of the light was
  6064. able to pass through it. For interesting variations of this texture, try
  6065. lowering ior to 1.15 and raising reflection to 0.5.
  6066.  
  6067. 4.8.4.6          Using Faked Caustics
  6068.  
  6069.  
  6070. 4.8.4.6.1        What are Caustics?
  6071.  
  6072. First, let us raid our kitchen cupboard. We are looking for transparent glass
  6073. or crystal drinking glasses. If they have a pattern etched in their surface,
  6074. so much the better. One by one, we place them under a bright lamp and observe
  6075. the shadow they cast on the desk or table beneath. If we look closely we will
  6076. make out bright regions within the shadow. These will be places where the
  6077. refractive properties of the drinking glass are concentrating light
  6078. sufficiently to make the bright spots. If there is a pattern in the surface
  6079. of the glass we will see the pattern formed out of the bright areas. Those
  6080. bright regions are the caustics caused by refraction, the refractice
  6081. caustics. There will also be bright patterns of light on the table that are
  6082. caused by light reflected off the glass. These are called reflective
  6083. caustics.
  6084.  
  6085. Once we know what we are looking for we will be able to spot caustics in many
  6086. everyday situations: the shadow cast by a magnifying glass has one, light
  6087. streaming through an aquarium might makes them, the light passing through a
  6088. piece of crumpled cellophane might cast them on the table top, etc. We will
  6089. even see them in the bottom of a swimming pool on a bright sunny day.
  6090. Caustics are a subtle lighting effect that can really lend realism to
  6091. raytraced images of such items.
  6092.  
  6093. POV-Ray uses algorithms that fake refractive caustics (reflective caustices
  6094. are not possible).There are inherant limitations on the process of (standard)
  6095. ray-tracing in general which make it unsuitable for certain light simulation
  6096. applications, such as optical testing and a few very particular architectural
  6097. lighting projects. Methods which do the considerably more extensive
  6098. calculations needed to do full light simulation including caustics (like
  6099. path-tracing, photon-tracing or bi-directional ray-tracing) are very slow and
  6100. impractical on average platforms.
  6101.  
  6102. This means that we have to tinker with the caustics to get the best possible
  6103. look, but with a little experimentation, we will see we can very closely
  6104. emulate the real thing. The best way to go is, where ever possible, to study
  6105. an example of the thing we are trying to trace. We need to get to know its
  6106. pattern of caustics and then adjust our final picture until we are satisfied.
  6107.  
  6108. 4.8.4.6.2        Applying Caustics to a Scene
  6109.  
  6110. Caustics is a new texture property under the area of finishes. We apply it to
  6111. the shadows of a transparent, refractive object by adding in the caustics
  6112. keyword to the finish. We try the following simple example for a start (see
  6113. file caustic1.pov).
  6114.  
  6115.   #include "colors.inc"
  6116.   #include "textures.inc"
  6117.  
  6118.   camera {
  6119.     location <0, 15, -40>
  6120.     look_at <-2, 0, 1>
  6121.     angle 10
  6122.   }
  6123.  
  6124.   light_source { <10, 20, 10> color White }
  6125.  
  6126.   // lay down a boring floor to view the shadow against
  6127.  
  6128.   plane { y, 0
  6129.     pigment { Grey }
  6130.   }
  6131.  
  6132.   // here's something to have caustics property applied
  6133.  
  6134.   sphere { <0, 3, 0>, 2
  6135.     texture {
  6136.       Glass3
  6137.       finish { caustics .6 }
  6138.     }
  6139.   }
  6140.  
  6141.  
  6142. The caustics in a swimming-pool.
  6143.  
  6144. When we render this we will see our sphere in the upper right corner of the
  6145. image, floating a little over the plane, and the shadow it casts is sprawled
  6146. across the central part of our view. And there in the center is a basic
  6147. caustic. That bright area in the center represents the light which normally
  6148. refractivity would concentrate in the middle of the shadow.
  6149.  
  6150. The only question this leaves is: what is with the floating point value which
  6151. follows the caustics keyword? Well, that's where our discussion above on
  6152. adjusting the caustic comes in. Remember the drinking glasses? If we had one
  6153. that had fairly thin walls and then a thick glass base we will see what we
  6154. mean in the shadows it casts. Above, with the thinner walls (with less
  6155. refraction) the caustics are less pronounced and more evenly diffused through
  6156. the shadow, but when we get to the part of the shadow cast by the thicker,
  6157. more refractive base, suddenly the caustic becomes more pronounced and more
  6158. tightly focused near the center.
  6159.  
  6160. Of course, since this is a simulated caustic, there is no correspondence
  6161. between the degree to which the caustic is focused or diffused and the shape,
  6162. size and refractivity of the object. But we can manually control it with the
  6163. floating point value following the caustic keyword. The closer this value
  6164. gets to zero, the more diffused and dimmer the caustic gets, while the nearer
  6165. it becomes to 1, the more tightly focused and pronounced the caustic gets. At
  6166. 1, we have the caustic of a thick, highly refractive piece of lead crystal,
  6167. while at 0.1 it is more like a hollow glass sphere. We try this by
  6168. re-rendering the above scene, with a range of values from 0.1 to 1.0 and
  6169. watching the different caustics we get.
  6170.  
  6171. Out of range values work also. Numbers higher than 1 just lead to more and
  6172. more tightly focused caustics. Negative numbers are just plain weird, but
  6173. interesting. Essentially, the object becomes illuminated in all sorts of
  6174. bizzare ways and the shadow becomes like a photographic negative of itself.
  6175. Kind of like a 1950's sci-fi raygun effect. It looks strange, and not at all
  6176. photo-realistic, but if we like the surreal we may want to try it at least
  6177. once and file away the effect in our mind in case we ever want it.
  6178.  
  6179. 4.8.4.6.3        Caustics And Normals
  6180.  
  6181. POV-Ray makes use of surface normal perturbation in a way that is more unique
  6182. than people generally stop to think. When we apply a surface normal in a
  6183. texture we are actually not altering the surface at all, but rather telling
  6184. POV-Ray to treat the surface as if it were altered, for purposes of computing
  6185. the illumination falling on each individual spot. In short, it is a trick of
  6186. the light and shadow which, supposing only that we don't see it at too sharp
  6187. a viewing angle, effectively creates the illusion of distortions in the
  6188. surface of an object.
  6189.  
  6190. Caustics are also a synthetic trick, as we saw above, and sure enough, they
  6191. have been designed to react to texture normal patterns as if those patterns
  6192. were genuinely there. Remember the drinking glass experiment? If we found a
  6193. glass with patterns etched into the surface we probably noted that the
  6194. pattern showed up in the caustics cast by the glass too. When we have a
  6195. transparent surface with a normal applied to it, it causes the caustics cast
  6196. by that surface to mimick the normal pattern, so that it shows up in the
  6197. shadows.
  6198.  
  6199. Following is an example of what we mean: it is a simply meant to represent
  6200. water in a swimming pool. We have distilled this down to a plane above to
  6201. represent the water, one below to represent the floor of the pool, a camera
  6202. just below the waterline, looking at the floor, and a light source high above
  6203. (see caustic2.pov).
  6204.  
  6205.   #include "colors.inc"
  6206.  
  6207.   // Our camera is underwater, looking at the bottom of
  6208.   // the pool for the best view of the caustics produced
  6209.  
  6210.   camera {
  6211.     location <0, -5, 0>
  6212.     look_at  <0, -10, -5>
  6213.   }
  6214.  
  6215.   light_source { <0, 100, 49.5> color White }
  6216.  
  6217.   // the bottom of the pool...
  6218.  
  6219.   plane { y, -10
  6220.     texture {
  6221.       pigment { color rgb <0.6, 0.7, 0.7> }
  6222.       finish { ambient 0.1 diffuse 0.7 }
  6223.       scale 0.01
  6224.     }
  6225.   }
  6226.  
  6227.   // and the surface of the water
  6228.  
  6229.   plane { y, 0
  6230.     texture {
  6231.       pigment { rgbf <0.6, 0.67, 0.72, 0.9> }
  6232.       normal {
  6233.         bumps .6
  6234.         scale <.75, .25, .25>
  6235.         rotate <0, 45, 0>
  6236.       }
  6237.       finish { caustics .9 }
  6238.     }
  6239.   }
  6240.  
  6241.  
  6242. The bumps we have given the water plane are meant to represent the small,
  6243. random crests and troughs that form on a pool when a light breeze blows over
  6244. it. We could have used ripples or waves as well, like something had recently
  6245. splashed into it at some point, but the bumps will work well enough for an
  6246. example.
  6247.  
  6248. We notice that our view of the pool floor shows dozens of tiny caustic light
  6249. spots, corresponding approximately to a random bump pattern. If we like we
  6250. can try putting in ripples or waves and watch the pattern of the caustics
  6251. change. Even though a flat plane itself would cast no caustics (we could try
  6252. without the normal), POV-Ray's faked caustic generation knows that if the
  6253. surface was really bumped like this normal is indicating, the refraction of
  6254. the bumped surface would be just enough to concentrate light in caustics
  6255. throughout the bottom of the pool.
  6256.  
  6257. We see that just as with a curved surface, such as the sphere previously,
  6258. normal patterns also trigger the appearance of caustics cast by an object.
  6259. Interestingly enough, this alone would be proof that the caustics really are
  6260. faked: our water hasn't even been given any refraction properties in its
  6261. finish, yet the caustics are still there just the same!
  6262.  
  6263. 4.8.4.7          Using Iridescence
  6264.  
  6265. Iridescence is what we see on the surface of an oil slick when the sun shines
  6266. on it. The rainbow effect is created by something called thin-film
  6267. interference (read section "Iridescence" for details). For now let's just try
  6268. using it. Iridescence is specified by the irid keyword and three values:
  6269. amount, thickness and turbulence. The amount is the contribution to the
  6270. overall surface color. Usually 0.1 to 0.5 is sufficient here. The thickness
  6271. affects the busyness of the effect. Keep this between 0.25 and 1 for best
  6272. results. The turbulence is a little different from pigment or normal
  6273. turbulence. We cannot set octaves, lambda or omega but we can specify an
  6274. amount which will affect the thickness in a slightly different way from the
  6275. thickness value. Values between 0.25 and 1 work best here too. Finally,
  6276. iridescence will respond to the surface normal since it depends on the angle
  6277. of incidence of the light rays striking the surface. With all of this in
  6278. mind, let's add some iridescence to our glass sphere.
  6279.  
  6280.   sphere { <0,0,0>, 1
  6281.     pigment { White filter 1 }
  6282.       finish {
  6283.         ambient .1
  6284.         diffuse .1
  6285.         reflection .2
  6286.         refraction 1
  6287.         ior 1.5
  6288.         specular 1
  6289.         roughness .001
  6290.         fade_distance 5
  6291.         fade_power 1
  6292.         caustics 1
  6293.         irid {
  6294.           0.35
  6295.           thickness .5
  6296.           turbulence .5
  6297.         }
  6298.      }
  6299.   }
  6300.  
  6301.  
  6302. We try to vary the values for amount, thickness and turbulence to see what
  6303. changes they make. We also try to add a normal block to see what happens.
  6304.  
  6305. 4.8.5            Halos
  6306.  
  6307. Important notice: The halo feature in POV-Ray 3.0 is somewhat experimental.
  6308. There is a high probability that the design and implementation of these
  6309. features will be changed in future versions. We cannot guarantee that scenes
  6310. using these features in 3.0 will render identically in future releases or
  6311. that full backwards compatibility of language syntax can be maintained.
  6312.  
  6313. Halos are a powerful feature that can be used to create a lot of different
  6314. effects like clouds, fogs, fire, lasers, etc. The name actually comes from
  6315. the ability to render halos with it, like the ones seen around the moon or
  6316. the sun.
  6317.  
  6318. Due to the complexity of the halo feature and the large amount of parameters
  6319. provided it is very difficult to get satisfying results. The following
  6320. sections will help to create a halo step by step, starting with the basic
  6321. things and going to the more subtle stuff.
  6322.  
  6323. It is also helpful to read the halo reference sections to get a better
  6324. understanding of the halo feature. One should especially read the sections
  6325. "Empty and Solid Objects" and "Halo Mapping"  because they are essential for
  6326. understanding halos.
  6327.  
  6328. 4.8.5.1          What are Halos?
  6329.  
  6330. Halos are a texture feature allowing us to fill the interior of an object
  6331. with particles. The distribution of these particles can be modified using
  6332. several density mappings and density functions. The particles can emit light
  6333. to give fire- or laser-like effects or they can absorb light to create clouds
  6334. or fog.
  6335.  
  6336. A halo is attached to an object, the so called container object, just like a
  6337. pigment, normal or finish. The container object is completely filled by the
  6338. halo but we will not see anything if we do not make sure that the object is
  6339. hollow and the surface is translucent. How this is accomplished will be shown
  6340. in the next section.
  6341.  
  6342. When working with halos we always have to keep in mind that the container
  6343. object has to be hollow and translucent.
  6344.  
  6345. 4.8.5.2          The Emitting Halo
  6346.  
  6347. We start with one of the simpler types, the emitting halo. It uses particles
  6348. that only emit light. There are no particles that absorb the light coming
  6349. from other particles or light sources.
  6350.  
  6351. 4.8.5.2.1        Starting with a Basic Halo
  6352.  
  6353. A clever approach in designing a nice halo effect is to start with a simple,
  6354. unit-sized shape that sits on the coordinate system's origin.
  6355.  
  6356. In the first example (halo01.pov) we try to create a fiery explosion, which
  6357. the sphere is best suited for. We start with a simple scene consisting of a
  6358. camera, a light source (we don't care about shadows so we add the shadowless
  6359. keyword), a checkered plane and a unit-sized sphere containing the halo.
  6360.  
  6361.   camera {
  6362.     location <0, 0, -2.5>
  6363.     look_at <0, 0, 0>
  6364.   }
  6365.  
  6366.   light_source { <10, 10, -10> color rgb 1 shadowless }
  6367.  
  6368.   plane { z, 2
  6369.     pigment { checker color rgb 0, color rgb 1 }
  6370.     finish { ambient 1 diffuse 0 }
  6371.     scale 0.5
  6372.     hollow
  6373.   }
  6374.  
  6375.   sphere { 0, 1
  6376.     pigment { color rgbt <1, 1, 1, 1> }
  6377.     halo {
  6378.       emitting
  6379.       spherical_mapping
  6380.       linear
  6381.       color_map {
  6382.         [ 0 color rgbt <1, 0, 0, 1> ]
  6383.         [ 1 color rgbt <1, 1, 0, 0> ]
  6384.       }
  6385.       samples 10
  6386.     }
  6387.     hollow
  6388.   }
  6389.  
  6390.  
  6391. We note that the sphere is set to be hollow and has a translucent surface
  6392. (the transmittance channel in the pigment's color is 1), just like it is
  6393. required for halos. We also note that the plane has a hollow keyword even
  6394. though it has no halo. Why is this necessary?
  6395.  
  6396. The reason is quite simple. As described in section "Empty and Solid Objects"
  6397. there can be no halo inside any other non-hollow object. Since the camera is
  6398. inside the plane object, i. e. it is on the side of the plane that is
  6399. considered to be inside, the halo will never be visible unless the plane is
  6400. made hollow (or the negative keyword is added to bring the camera on the
  6401. outside side of the plane).
  6402.  
  6403. What do all those halo keywords and values mean? At the beginning of the halo
  6404. the emitting keyword is used to specify what type of halo we want to use. The
  6405. emitting halo emits light. That is what is best suited for our fiery
  6406. explosion.
  6407.  
  6408. The spherical_mapping and linear keywords need a more detailed explanation of
  6409. how a halo works (this is also done in chapter "Halo" in more detail).
  6410.  
  6411. As noted above the halo is made up of lots of small particles. The
  6412. distribution of these particles is described by a density function. In
  6413. general, a density function tells us how much particles we'll find at a given
  6414. location.
  6415.  
  6416. Instead of using an explicitly, mathematical density function, halos rely on
  6417. a given set of density mappings and density functions to model a variety of
  6418. particle distributions.
  6419.  
  6420. The first step in this model is the density mapping function that is used to
  6421. map three-dimensional points onto a one-dimensional range of values. In our
  6422. example we use a spherical mapping, i.e. we take the distance of a point from
  6423. the center of the coordinate system. This is the reason why it is clever to
  6424. start with a container object sitting on the coordinate system's center.
  6425. Since all density mappings are made relative to this center we won't see
  6426. anything if we start with an object sitting somewhere else. Moving the whole
  6427. object (including textures and halos) to another location is the correct way
  6428. of placing a container object.
  6429.  
  6430. Now we have a single value in the range from 0 to 1. This value will be
  6431. transformed using a density function to get density values instead of
  6432. distance values. Just using this single value won't work because we want to
  6433. have particle distributions were the density decreases as we move from the
  6434. center of the container object to the outside.
  6435.  
  6436. This is done by the density function. There are several alternatives
  6437. available as described in the halo reference (see section "Density Function"
  6438. ). We use the simple linear function that just maps values between 0 and 1
  6439. onto a 1 to 0 range. Thus we get a density value of 1 at the center of our
  6440. sphere and a value of 0 at its surface.
  6441.  
  6442. Now that we have a density function what do we do to see something? This is
  6443. where the colour_map keyword comes into play. It is used to describe a color
  6444. map that actually tells the program what colors are to be used for what
  6445. density. The relation is quite simple: colors at the beginning of the color
  6446. map (with small values) will be used for low density values and colors at the
  6447. end of the map (high values) will be used for high densities. In our example
  6448. the halo will be yellow at the center of the sphere where the density is
  6449. greatest and it will blend to red at the surface of the sphere where the
  6450. density approaches zero.
  6451.  
  6452. The transmittance channel of the colors in the color map is used to model the
  6453. translucency of the density field. A value of 0 represents no translucency,
  6454. i. e. that areas with the corresponding density will be (almost) opaque,
  6455. while a value of 1 means (almost) total translucency.
  6456.  
  6457. In our example we use
  6458.  
  6459.   color_map {
  6460.     [ 0 color rgbt <1, 0, 0, 1> ]
  6461.     [ 1 color rgbt <1, 1, 0, 0> ]
  6462.   }
  6463.  
  6464.  
  6465. which results in a halo with a very translucent, reddish outer area and a
  6466. nearly opaque, yellowish inner areas as we can see after tracing the example
  6467. image.
  6468.  
  6469. The basic halo used in modelling a fiery explosion.
  6470.  
  6471. There is one parameter that still needs to be explained: the samples keyword.
  6472. This keyword tells POV-Ray how many samples have to be taken along any ray
  6473. traveling through the halo to calculate its effect. Using a low value will
  6474. result in a high tracing speed while a high value will lead to a low speed.
  6475. The sample value has to be increased if the halo looks somewhat noisy, i. e.
  6476. if some artifacts of the low sampling rate appear. For more details see
  6477. section "Halo Sampling".
  6478.  
  6479.  
  6480.  
  6481. 4.8.5.2.2        Increasing the Brightness
  6482.  
  6483. The colors of the halo in the above image are somewhat dim. There is too much
  6484. of the background visible through the halo. That does not look much like
  6485. fire, does it? An easy way to fix this is to decrease the transparency of the
  6486. particles in the areas of high density. We do this by using use the following
  6487. color map instead of the old one (the negative transmittance is correct).
  6488.  
  6489.   color_map {
  6490.     [ 0 color rgbt <1, 0, 0,  1> ]
  6491.     [ 1 color rgbt <1, 1, 0, -1> ]
  6492.   }
  6493.  
  6494.  
  6495. Looking at the result of halo02.pov we see that the halo is indeed much
  6496. brighter.
  6497.  
  6498.  
  6499. 4.8.5.2.3        Adding Some Turbulence
  6500.  
  6501. What we now have does not look like a fiery explosion. It's more a glowing
  6502. ball than anything else. Somehow we have to make it look more chaotic, we
  6503. have to add some turbulence to it.
  6504.  
  6505. This is done by using the turbulence keyword together with the amount of
  6506. turbulence we want to add. Just like in the following example.
  6507.  
  6508.   sphere { 0, 1
  6509.     pigment { color rgbt <1, 1, 1, 1> }
  6510.     halo {
  6511.       emitting
  6512.       spherical_mapping
  6513.       linear
  6514.       turbulence 1.5
  6515.       color_map {
  6516.         [ 0 color rgbt <1, 0, 0,  1> ]
  6517.         [ 1 color rgbt <1, 1, 0, -1> ]
  6518.       }
  6519.       samples 10
  6520.     }
  6521.     hollow
  6522.   }
  6523.  
  6524.  
  6525. Adding turbulence to the halo moves all points inside the halo container in a
  6526. pseudo-random manner. This results in a particle distribution that looks like
  6527. there was some kind of flow in the halo (depending on the amount of
  6528. turbulence we'll get a laminar or turbulent flow). The high turbulence value
  6529. is used because an explosion is highly turbulent.
  6530.  
  6531. Looking at the example image (halo03.pov) we'll see that this looks more like
  6532. a fiery explosion than the glowing ball we got until now.
  6533.  
  6534. Adding some turbulence makes the fiery explosion more realistic.
  6535.  
  6536. We notice that the time it took to render the image increased after we added
  6537. the turbulence. This is due to the fact that for every sample taken from the
  6538. halo the slow turbulence function has to be evaluated.
  6539.  
  6540. 4.8.5.2.4        Resizing the Halo
  6541.  
  6542. There is one strange thing about our fiery explosion though. It still looks
  6543. like a sphere. Why does this happen and what can we do to avoid it?
  6544.  
  6545. As noted above adding turbulence moves the particles inside the halo
  6546. container around. The problem is that some of the particles are actually
  6547. moved out of the container object. This leads to high densities at the
  6548. surface of the container object revealing the shape of the object (all
  6549. particles outside the container are lost and will not visible resulting in a
  6550. large, highly visible density change at the surface).
  6551.  
  6552. An easy way of avoiding this is to make sure that the particles stay inside
  6553. the container object even if we add some turbulence. This is done by scaling
  6554. the halo to reduce its size. We do not scale the container object, just the
  6555. halo.
  6556.  
  6557. This is done by adding the scale keyword inside the halo statement.
  6558.  
  6559.   sphere { 0, 1
  6560.     pigment { color rgbt <1, 1, 1, 1> }
  6561.     halo {
  6562.       emitting
  6563.       spherical_mapping
  6564.       linear
  6565.       turbulence 1.5
  6566.       color_map {
  6567.         [ 0 color rgbt <1, 0, 0,  1> ]
  6568.         [ 1 color rgbt <1, 1, 0, -1> ]
  6569.       }
  6570.       samples 10
  6571.       scale 0.5
  6572.     }
  6573.     hollow
  6574.     scale 1.5
  6575.   }
  6576.  
  6577.  
  6578. The scale 0.5 command tells POV-Ray to scale all points inside the halo by
  6579. this amount. This effectively scales the radius we get after the density
  6580. mapping to a range of 0 to 0.5 instead of 0 to 1 (without turbulence). If we
  6581. now add the turbulence the points are allowed to move half a unit in every
  6582. direction without leaving the container object. That is exactly what we want.
  6583.  
  6584.  
  6585. To compensate for the smaller halo we would get we scale the sphere (and the
  6586. halo inside) by 1.5.
  6587.  
  6588. Looking at the new example image (halo04.pov) we will no longer see any signs
  6589. of the container sphere. We finally have a nice fiery explosion.
  6590.  
  6591. Resizing the halo makes it look much better.
  6592.  
  6593. The amount by which to scale the halo depends on the amount of turbulence we
  6594. use. The higher the turbulence value the smaller the halo has to be scaled.
  6595. That is something to experiment with.
  6596.  
  6597. Another way to avoid that points move out of the sphere is to use a larger
  6598. sphere, i. e. a sphere with a radius larger than one. It is important to
  6599. re-size the sphere before the halo is added because otherwise the halo will
  6600. also be scaled.
  6601.  
  6602. We note that this only works for spherical and box mapping (and a
  6603. non-constant density function). All other mapping types are (partially)
  6604. infinite, i. e. the resulting particle distribution covers an infinite space
  6605. (see also "Halo Mapping").
  6606.  
  6607. 4.8.5.2.5        Using Frequency to Improve Realism
  6608.  
  6609. Another very good way of improving the realism of our explosion is to use a
  6610. frequency value other than one. The way frequency works is explained in
  6611. section "Frequency Modifier" in the reference part.
  6612.  
  6613. The rather mathematical explanation used there doesn't help much in
  6614. understanding how this feature is used. It is quite simple though. The
  6615. frequency value just tells the program how many times the color map will be
  6616. repeated in the density range from 0 to 1. If a frequency of one (the
  6617. default) is specified the color map will be visible once in the density
  6618. field, e. g. the color at 0 will be used for density 0, color at 0.5 will be
  6619. used for density 0.5 and the color at 1 will be used for density 1. Simple,
  6620. isn't it?
  6621.  
  6622. If we choose a frequency of two, the color at 0 will be used for density 0,
  6623. the color at 0.5 will be used for density 0.25 and the color at 1 will be
  6624. used for density 0.5. What about the densities above 0.5? Since there are no
  6625. entries in the color map for values above 1 we just start at 0 again. Thus
  6626. the color at 0.1 will be used for density 0.55 ((2*0.55) mod 1 = 1.1 mod 1 =
  6627. 0.1), the color at 0.5 will be used for density 0.75 and the color at 1 will
  6628. be used for density 1.
  6629.  
  6630. If we are good at mathematics we'll note that the above example is not quite
  6631. right because (1 * 2) mod 1 = 0 and not 1. We just think that we used a value
  6632. slightly smaller than one and everything will be fine.
  6633.  
  6634. We may have noticed that in order to avoid sudden changes in the halo color
  6635. for frequencies larger than one we'll have to used a periodic color map, i.e.
  6636. a color map whose entries at 0 and 1 are the same.
  6637.  
  6638. We'll change our example by using a periodic color map and changing the
  6639. frequency value to two.
  6640.  
  6641.   sphere { 0, 1
  6642.     pigment { color rgbt <1, 1, 1, 1> }
  6643.     halo {
  6644.       emitting
  6645.       spherical_mapping
  6646.       linear
  6647.       turbulence 1.5
  6648.       color_map {
  6649.         [ 0.0 color rgbt <1, 0, 0,  1> ]
  6650.         [ 0.5 color rgbt <1, 1, 0, -1> ]
  6651.         [ 1.0 color rgbt <1, 0, 0,  1> ]
  6652.       }
  6653.       frequency 2
  6654.       samples 20
  6655.       scale 0.5
  6656.     }
  6657.     hollow
  6658.     scale 1.5
  6659.   }
  6660.  
  6661.  
  6662. Using a periodic color map and a frequency of two gives a much nicer
  6663. explosion.
  6664.  
  6665. Looking at the result of (halo05.pov) we can be quite satisfied with the
  6666. explosion we just have created, can't we?
  6667.  
  6668. There's one thing left we should be aware of when increasing the frequency
  6669. value. It is often necessary to increase the sample rate in (nearly) the same
  6670. way as we change the frequency. If we don't do this we'll probably get some
  6671. severe aliasing artifacts (like color jumps or strange bands of colors). If
  6672. this happens just change the samples value according to the frequency value
  6673. (twice sampling rate for a doubled frequency).
  6674.  
  6675. 4.8.5.2.6        Changing the Halo Color
  6676.  
  6677. We have a nice fiery explosion but we want to try to add some science fiction
  6678. touch to it by using different colors. How about a nice green, less turbulent
  6679. explosion that gets red at its borders?
  6680.  
  6681. Nothing easier than that!
  6682.  
  6683.   sphere { 0, 1.5
  6684.     pigment { color rgbt <1, 1, 1, 1> }
  6685.     halo {
  6686.       emitting
  6687.       spherical_mapping
  6688.       linear
  6689.       turbulence 0.5
  6690.       color_map {
  6691.         [ 0 color rgbt <0, 1, 0,  1> ]
  6692.         [ 1 color rgbt <1, 0, 0, -1> ]
  6693.       }
  6694.       samples 10
  6695.       scale 0.75
  6696.     }
  6697.     hollow
  6698.     scale 1.5
  6699.   }
  6700.  
  6701.  
  6702. Using red and green colors gives an unexpected result.
  6703.  
  6704. This should do the trick. Looking at the result of halo06.pov we may be
  6705. disappointed. Where is the red center of the explosion? The borders are green
  6706. as expected but there is a lot of yellow in the center and only a little bit
  6707. red. What is happening?
  6708.  
  6709. We use an emitting halo in our example. According to the corresponding
  6710. section in the halo reference chapter (see "Emitting") this type of halo uses
  6711. very small particles that do not attenuate light passing through the halo.
  6712. Especially particles near the viewer do not attenuate the light coming from
  6713. particles far away from the viewer.
  6714.  
  6715. During the calculation of the halo's color near the center of the container
  6716. sphere, the ray steps through nearly all possible densities of the particle
  6717. distribution. Thus we get red and green colors as we march on, depending on
  6718. the current position in the halo. The sum of these colors is used which will
  6719. gives as a yellow color (the sum of red and green is yellow). This is what is
  6720. happening here.
  6721.  
  6722. How can we still get what we want? The answer is to use a glowing halo
  6723. instead of the emitting halo. The glowing halo is very similar to the
  6724. emitting one except that it attenuates the light passing through. Thus the
  6725. light of particles lying behind other particles will be attenuated by the
  6726. particles in front.
  6727.  
  6728.  
  6729. 4.8.5.3          The Glowing Halo
  6730.  
  6731. We have mentioned the glowing halo in the section about the emitting halo as
  6732. one way to avoid the color mixing that is happening with emitting halos.
  6733.  
  6734. The glowing halo is very similar to the emitting halo except that it also
  6735. absorbs light. We can view it as a combination of the emitting and the
  6736. attenuating halo described in section "The Attenuating Halo".
  6737.  
  6738. By just replacing the emitting keyword in the example in section "Changing
  6739. the Halo Color" with the glowing keyword we get the desired effect as shown
  6740. in the example image (halo11.pov).
  6741.  
  6742. Using a glowing halo gives the expected result.
  6743.  
  6744. Even though the red color of the high density areas is not very visible
  6745. because the green colored, lower density areas lying in front absorb most of
  6746. the red light, we don't get yellow color where we would have expected a red
  6747. one.
  6748.  
  6749. Due to its similarity with the emitting halo we have to make some experiments
  6750. with this halo type. We just have to keep all those things we learned in the
  6751. previous sections in mind to get some satisfying results.
  6752.  
  6753. 4.8.5.4          The Attenuating Halo
  6754.  
  6755. Another simple halo type is the attenuating halo that only absorbs light. It
  6756. doesn't radiate on its own.
  6757.  
  6758. A great difference between the attenuating halo and the other halo types is
  6759. that the color of the attenuating halo is calculated from the halo's color
  6760. map using the total particle density along a given ray. The other types
  6761. calculated a (weighted) average of the colors calculated from the density at
  6762. each sample.
  6763.  
  6764. 4.8.5.4.1        Making a Cloud
  6765.  
  6766. Attenuating halos are ideal to create clouds and smoke. In the following
  6767. examples we will try to make a neat little cloud. We start again by using a
  6768. unit-sized sphere that is filled with a basic attenuating halo (halo21.pov).
  6769.  
  6770.   camera {
  6771.     location <0, 0, -2.5>
  6772.     look_at <0, 0, 0>
  6773.   }
  6774.  
  6775.   light_source { <10, 10, -10> color rgb 1 shadowless }
  6776.  
  6777.   plane { z, 2
  6778.     pigment { checker color rgb 0, color rgb 1 }
  6779.     finish { ambient 1 diffuse 0 }
  6780.     scale 0.5
  6781.     hollow
  6782.   }
  6783.  
  6784.   sphere { 0, 1
  6785.     pigment { color rgbt <1, 1, 1, 1> }
  6786.     halo {
  6787.       attenuating
  6788.       spherical_mapping
  6789.       linear
  6790.       color_map {
  6791.         [ 0 color rgbt <1, 0, 0, 1> ]
  6792.         [ 1 color rgbt <1, 0, 0, 0> ]
  6793.       }
  6794.       samples 10
  6795.     }
  6796.     hollow
  6797.   }
  6798.  
  6799.  
  6800. Even though clouds normally are not red but white or gray, we use the red
  6801. color to make it more visible against the black/white checkerboard
  6802. background.
  6803.  
  6804. The color of an attenuating halo is calculated from the total accumulated
  6805. density after a ray has marched through the complete particle field. This has
  6806. to be kept in mind when creating the color map. We want the areas of the
  6807. cloud with a low density to have a high translucency so we use a color of
  6808. rgbt<1,0,0,1> and we want the high density areas to be opaque so we choose a
  6809. color of rgbt<1,0,0,0>.
  6810.  
  6811.  
  6812. 4.8.5.4.2        Scaling the Halo Container
  6813.  
  6814. The cloud we have created so far doesn't look very realistic. It's just a
  6815. red, partially translucent ball. In order to get a better result we use some
  6816. of the methods we have already learned in the sections about emitting halos
  6817. above. We add some turbulence to get a more realistic shape, we scale the
  6818. halo to avoid the container object's surface to become visible and we
  6819. decrease the translucency of the areas with a high particle density.
  6820.  
  6821. Another idea is to scale the container object to get an ellipsoid shape that
  6822. can be used to model a cloud pretty good. This is done by the scale <1.5,
  6823. 0.75, 1> command at the end of the sphere. It scales both, the sphere and the
  6824. halo inside.
  6825.  
  6826.   sphere { 0, 1
  6827.     pigment { color rgbt <1, 1, 1, 1> }
  6828.     halo {
  6829.       attenuating
  6830.       spherical_mapping
  6831.       linear
  6832.       turbulence 1
  6833.       color_map {
  6834.         [ 0 color rgbt <1, 0, 0,  1> ]
  6835.         [ 1 color rgbt <1, 0, 0, -1> ]
  6836.       }
  6837.       samples 10
  6838.       scale 0.75
  6839.     }
  6840.     hollow
  6841.     scale <1.5, 0.75, 1>
  6842.   }
  6843.  
  6844.  
  6845. Looking at the results of halo22.pov we see that this looks more like a real
  6846. cloud (besides the color).
  6847.  
  6848.  
  6849. 4.8.5.4.3        Adding Additional Halos
  6850.  
  6851. Another trick to get some more realism is to use multiple halos. If we look
  6852. at cumulus clouds e. g. we notice that they often extend at the top while
  6853. they are quite flat at the bottom.
  6854.  
  6855. We want to model this appearance by adding two additional halos to our
  6856. current container object (see section "Multiple Halos" for more details).
  6857. This is done in the following way:
  6858.  
  6859.   sphere { 0, 1.5
  6860.     pigment { color rgbt <1, 1, 1, 1> }
  6861.     halo {
  6862.       attenuating
  6863.       spherical_mapping
  6864.       linear
  6865.       turbulence 1
  6866.       color_map {
  6867.         [ 0 color rgbt <1, 0, 0,  1> ]
  6868.         [ 1 color rgbt <1, 0, 0, -1> ]
  6869.       }
  6870.       samples 10
  6871.       scale <0.75, 0.5, 1>
  6872.       translate <-0.4, 0, 0>
  6873.     }
  6874.     halo {
  6875.       attenuating
  6876.       spherical_mapping
  6877.       linear
  6878.       turbulence 1
  6879.       color_map {
  6880.         [ 0 color rgbt <1, 0, 0,  1> ]
  6881.         [ 1 color rgbt <1, 0, 0, -1> ]
  6882.       }
  6883.       samples 10
  6884.       scale <0.75, 0.5, 1>
  6885.       translate <0.4, 0, 0>
  6886.     }
  6887.     halo {
  6888.       attenuating
  6889.       spherical_mapping
  6890.       linear
  6891.       turbulence 1
  6892.       color_map {
  6893.         [ 0 color rgbt <1, 0, 0,  1> ]
  6894.         [ 1 color rgbt <1, 0, 0, -1> ]
  6895.       }
  6896.       samples 10
  6897.       scale 0.5
  6898.       translate <0, 0.2, 0>
  6899.     }
  6900.     hollow
  6901.   }
  6902.  
  6903.  
  6904. The three halos used differ only in their location, i. e. in the translation
  6905. vector we have used. The first two halos are used to form the base of the
  6906. cloud while the last sits on top of the others. The sphere has a different
  6907. radius than the previous ones because more space is needed for all three
  6908. halos.
  6909.  
  6910. The result of halo23.pov somewhat looks like a cloud, even though it may need
  6911. some work.
  6912.  
  6913.  
  6914. 4.8.5.5          The Dust Halo
  6915.  
  6916. The dust halo is a very complex halo type. It allows us to see the
  6917. interaction of light coming from a light source with the particles in the
  6918. halo. These particles absorb light in the same way as the attenuating halo.
  6919. In addition they scatter the incoming light. This makes beams of light and
  6920. shadows cast by objects onto the halo become visible.
  6921.  
  6922. 4.8.5.5.1        Starting With an Object Lit by a Spotlight
  6923.  
  6924. We start with a box shaped object that is lit by a spotlight. We don't use
  6925. any halo at this moment because we want to see if the object is completely
  6926. lit by the light (halo31.pov).
  6927.  
  6928.   camera {
  6929.     location <0, 0, -2.5>
  6930.     look_at <0, 0, 0>
  6931.   }
  6932.  
  6933.   background { color rgb <0.2, 0.4, 0.8> }
  6934.  
  6935.   light_source {
  6936.     <2.5, 2.5, -2.5>
  6937.     colour rgb <1, 1, 1>
  6938.     spotlight
  6939.     point_at <0, 0, 0>
  6940.     radius 12
  6941.     falloff 15
  6942.     tightness 1
  6943.   }
  6944.  
  6945.   difference {
  6946.     box { -1, 1 }
  6947.     box { <-1.1, -0.8, -0.8>, <1.1, 0.8, 0.8> }
  6948.     box { <-0.8, -1.1, -0.8>, <0.8, 1.1, 0.8> }
  6949.     box { <-0.8, -0.8, -1.1>, <0.8, 0.8, 1.1> }
  6950.     pigment { color rgb <1, 0.2, 0.2> }
  6951.     scale 0.5
  6952.     rotate 45*y
  6953.     rotate 45*x
  6954.   }
  6955.  
  6956.  
  6957. The object we want to use.
  6958.  
  6959. As we see the whole object is lit by the light source. Now we can start to
  6960. add some dust.
  6961.  
  6962. 4.8.5.5.2        Adding Some Dust
  6963.  
  6964. We use a box to contain the dust halo. Since we use a constant density
  6965. function it doesn't matter what kind of density mapping we use. The density
  6966. has the value specified by the max_value keyword everywhere inside the halo
  6967. (the default value is one). The isotropic scattering is selected with
  6968. dust_type .
  6969.  
  6970.   box { -1, 1
  6971.     pigment { colour rgbt <1, 1, 1, 1> }
  6972.     halo {
  6973.       dust
  6974.       dust_type 1
  6975.       box_mapping
  6976.       constant
  6977.       colour_map {
  6978.         [ 0 color rgbt <1, 1, 1, 1> ]
  6979.         [ 1 color rgbt <1, 1, 1, 0> ]
  6980.       }
  6981.       samples 10
  6982.     }
  6983.     hollow
  6984.     scale 5
  6985.   }
  6986.  
  6987.  
  6988. This dust is too thick.
  6989.  
  6990. The result of halo32.pov is too bright. The dust is too thick and we can only
  6991. see some parts of the object and no background.
  6992.  
  6993. 4.8.5.5.3        Decreasing the Dust Density
  6994.  
  6995. The density inside the halo has the constant value one. This means that only
  6996. the color map entry at position one is used to determine the density and
  6997. color of the dust.
  6998.  
  6999. We use a transmittance value of 0.7 to get a much thinner dust.
  7000.  
  7001.   box { -1, 1
  7002.     pigment { colour rgbt <1, 1, 1, 1> }
  7003.     halo {
  7004.       dust
  7005.       dust_type 1
  7006.       box_mapping
  7007.       constant
  7008.       colour_map {
  7009.         [ 0 color rgbt <1, 1, 1, 1.0> ]
  7010.         [ 1 color rgbt <1, 1, 1, 0.7> ]
  7011.       }
  7012.       samples 10
  7013.     }
  7014.     hollow
  7015.     scale 5
  7016.   }
  7017.  
  7018.  
  7019. A thinner dust looks much better.
  7020.  
  7021. Beside the ugly aliasing artifacts the image looks much better. We can see
  7022. the whole object and even the background is slightly visible (halo33.pov).
  7023.  
  7024. 4.8.5.5.4        Making the Shadows Look Good
  7025.  
  7026. In order to reduce the aliasing artifacts we use three different techniques:
  7027. jittering, super-sampling and an increased overall sampling rate.
  7028.  
  7029. The jittering is used to add some randomness to the sampling points making
  7030. the image look more noisy. This helps because regular aliasing artifacts are
  7031. more annoying than noise. A low jitter value is a good choice.
  7032.  
  7033. The super-sampling tries to detect fine features by taking additional samples
  7034. in areas of high intensity changes. The threshold at which super-sampling is
  7035. used and the maximum recursion level can be specified using the aa_threshold
  7036. and aa_level keywords.
  7037.  
  7038. The approach that always works is to increase the overall sampling rate.
  7039. Since this is also the slowest method we should always try to use the other
  7040. methods first. If they don't suffice we have to increase the sampling rate.
  7041.  
  7042. We use the following halo to reduce the aliasing artifacts (halo34.pov).
  7043.  
  7044.   box { -1, 1
  7045.     pigment { colour rgbt <1, 1, 1, 1> }
  7046.     halo {
  7047.       dust
  7048.       dust_type 1
  7049.       box_mapping
  7050.       constant
  7051.       colour_map {
  7052.         [ 0 color rgbt <1, 1, 1, 1.0> ]
  7053.         [ 1 color rgbt <1, 1, 1, 0.7> ]
  7054.       }
  7055.       samples 50
  7056.       aa_level 3
  7057.       aa_threshold 0.2
  7058.       jitter 0.1
  7059.     }
  7060.     hollow
  7061.     scale 5
  7062.   }
  7063.  
  7064.  
  7065. Different anti-aliasing methods help to get a satisfying result.
  7066.  
  7067. The image looks much better now. There are hardly any aliasing artifacts
  7068. left.
  7069.  
  7070. The same parameters we have used are discussed in the section about the
  7071. atmosphere feature (see "The Atmosphere" for further explanations).
  7072.  
  7073. 4.8.5.5.5        Adding Turbulence
  7074.  
  7075. The major difference between the halo's dust and the atmosphere described in
  7076. "The Atmosphere" is the ability to choose a non-uniform particle distribution
  7077. for the dust. This includes the fact that the halo is limited to a container
  7078. object as well as the different density mappings and functions.
  7079.  
  7080. Another interesting way of getting an irregular distribution is to add some
  7081. turbulence to the dust. This is done with the turbulence keyword followed by
  7082. the amount of turbulence to use, like the following example shows
  7083. (halo35.pov).
  7084.  
  7085.   box { -1, 1
  7086.     pigment { colour rgbt <1, 1, 1, 1> }
  7087.     halo {
  7088.       dust
  7089.       dust_type 1
  7090.       box_mapping
  7091.       linear
  7092.       turbulence 1
  7093.       colour_map {
  7094.         [ 0 color rgbt <1, 1, 1, 1.0> ]
  7095.         [ 1 color rgbt <1, 1, 1, 0.5> ]
  7096.       }
  7097.       samples 50
  7098.       aa_level 3
  7099.       aa_threshold 0.2
  7100.       jitter 0.1
  7101.     }
  7102.     hollow
  7103.     scale 5
  7104.   }
  7105.  
  7106.  
  7107. Adding turbulence to the dust makes it much more interesting.
  7108.  
  7109. The image we now get looks much more interesting due to the shifts in the
  7110. particle density.
  7111.  
  7112. We should note that we use a linear density function instead of the previous
  7113. constant one. This is necessary because with a constant density function the
  7114. density has the same value everywhere. Adding turbulence would have no effect
  7115. because wherever the points are moved the density will have this same value.
  7116. Only a non-constant density distribution makes sense when turbulence is
  7117. added.
  7118.  
  7119. The fact that the turbulence value is actually a vector can be used to create
  7120. effects like waterfalls by using a large turbulence value in one direction
  7121. only (e.g. turbulence <0.2, 1, 0.2> ).
  7122.  
  7123. 4.8.5.5.6        Using a Coloured Dust
  7124.  
  7125. If we want to create a colored dust we can easily do this by using a
  7126. non-white color in the halo's color map. In this case we'll also have to set
  7127. the filter channels in the color map to non-zero values to specify the amount
  7128. of light that will be filtered by the dust's color.
  7129.  
  7130. We use the following color map to get a partially filtering, red dust for
  7131. example:
  7132.  
  7133.   colour_map {
  7134.     [ 0 color rgbft <1, 0, 0, 0.5, 1.0> ]
  7135.     [ 1 color rgbft <1, 0, 0, 0.5, 0.7> ]
  7136.   }
  7137.  
  7138.  
  7139. 4.8.5.6          Halo Pitfalls
  7140.  
  7141. Due to the complexity of the halo feature and the few experiences people have
  7142. made so far there are a lot of things still to discover.
  7143.  
  7144. Some of the most common problems and pitfalls are described below to help us
  7145. avoid the most common problems.
  7146.  
  7147. 4.8.5.6.1        Where Halos are Allowed
  7148.  
  7149. As mentioned above a halo completly fills the interior of an object. Keeping
  7150. this in mind it is reasonable that the following example does not make sense.
  7151.  
  7152.  
  7153.   sphere { 0, 1
  7154.     pigment {
  7155.       checker
  7156.       texture {
  7157.         pigment { color Clear }
  7158.         halo { ... }
  7159.       }
  7160.       texture {
  7161.         pigment { color Red }
  7162.       }
  7163.     }
  7164.     hollow
  7165.   }
  7166.  
  7167.  
  7168. What's wrong with this example? It's simply that a halo is used to describe
  7169. the interior of an object and that one cannot describe this interior by
  7170. describing how the surface of the object looks like. But that's what was done
  7171. in the example above. We cannot imagine what the interior of the sphere will
  7172. look like. Will it be filled completey with the halo? Will there be areas
  7173. filled by the halo and some filled by air? How will those areas look like?
  7174.  
  7175. We won't be able to tell the interior's properties from looking at the
  7176. surface. It's just not possible. This should always be kept in mind.
  7177.  
  7178. If the above example was meant to create a sphere filled with a halo and
  7179. covered with a checker board pattern that partially hid the halo we would
  7180. have used the following syntax:
  7181.  
  7182.   sphere { 0, 1
  7183.     pigment {
  7184.       checker
  7185.       texture {
  7186.         pigment { color Clear }
  7187.       }
  7188.       texture {
  7189.         pigment { color Red }
  7190.       }
  7191.     }
  7192.     halo { ... }
  7193.     hollow
  7194.   }
  7195.  
  7196.  
  7197. A halo is always applied to an object in the following way:
  7198.  
  7199.   OBJECT {
  7200.     texture {
  7201.       pigment { ... }
  7202.       normal { ... }
  7203.       finish { ... }
  7204.       halo { ... }
  7205.     }
  7206.     hollow
  7207.   }
  7208.  
  7209.  
  7210. There's no halo allowed inside any pigment statement, color map, pigment map,
  7211. texture map, material map, or whatever. We are not hindered to do this but we
  7212. will not get what we want.
  7213.  
  7214. We can use halos with a layered textures as long as we make sure that the
  7215. halos are only attached to the lowest layer (this layer has to be partially
  7216. transparent to see the halo of course).
  7217.  
  7218. 4.8.5.6.2        Overlapping Container Objects
  7219.  
  7220. POV-Ray is not able to handle overlapping container objects correctly. If we
  7221. create two overlapping spheres that contain a halo we won't get correct
  7222. results where the spheres overlap. The halo effect is calculated
  7223. independently for each sphere and the results are added.
  7224.  
  7225. If we want to add different halos we have to put all halos inside a single
  7226. container object to make sure the halo is calculated correctly (see also
  7227. "Multiple Halos").
  7228.  
  7229. We should also note that non-overlapping, stacked halo containers are handled
  7230. correctly. If we put a container object in front of another container object
  7231. the halos are rendered correctly.
  7232.  
  7233. 4.8.5.6.3        Multiple Attenuating Halos
  7234.  
  7235. It is currently not possible to use multiple attenuating halos with different
  7236. color maps. The color map of the last halo will be used for all halos in the
  7237. container object.
  7238.  
  7239. 4.8.5.6.4        Halos and Hollow Objects
  7240.  
  7241. In order to correctly render halo effects we have to make sure that all
  7242. objects the camera is inside are hollow. This is done by adding the hollow
  7243. keyword.
  7244.  
  7245.  
  7246. 4.8.5.6.5        Scaling a Halo Container
  7247.  
  7248. If we scale a halo container object we should keep in mind that it makes a
  7249. great difference where we place the scale keyword.
  7250.  
  7251. Scaling the object before the halo statement will only scale the container
  7252. object not the halo. This is useful if we want to avoid that the surface of
  7253. the container object becomes visible due to the use of turbulence. As we have
  7254. learned in the sections above particles may move out of the container object
  7255. - where they are invisible - if turbulence is added. This only works for
  7256. spherical and box mapping because the density fields described by the other
  7257. mapping types don't have finite dimensions.
  7258.  
  7259. If the scale keyword is used after the halo statement both, the halo and the
  7260. container object, are scaled. This is useful to scale the halo to our needs.
  7261.  
  7262. The halo keeps its appearance regardless of the transformations applied to
  7263. the container object (after the halo), i.e. the halo's translucency, color
  7264. and turbulence characteristics will not change.
  7265.  
  7266. 4.8.5.6.6        Choosing a Sampling Rate
  7267.  
  7268. Normally we will start with a low sampling rate and we willl only increase it
  7269. if any aliasing artifacts show up (and don't vanish by using super-sampling
  7270. and jittering).
  7271.  
  7272. The halo's appearance is independent from the sampling rate as long as there
  7273. are enough samples to get a good estimate of what the halo really looks like.
  7274. This means that one or two samples are hardly ever enough to determine the
  7275. halo's appearance. As we increase the number of samples the halo will quickly
  7276. approach its real appearance.
  7277.  
  7278. To put it in a nutshell, the halo will not change its appearance with the
  7279. sample rate as long as we have a sufficient number of samples and no aliasing
  7280. artifacts occur.
  7281.  
  7282. 4.8.5.6.7        Using Turbulence
  7283.  
  7284. As noted in one of the above sections turbulence will have no effect if the
  7285. constant density function is used (keyword constant). It doesn't matter how
  7286. much or where we move a point if the density is constant and thus does not
  7287. depend on the location of the point. We'll get the same density value for all
  7288. location.
  7289.  
  7290. Whenever we add turbulence to a halo we must not use the constant density
  7291. function.
  7292.  
  7293. 4.9              Working With Special Textures
  7294.  
  7295. Many of the pigment patterns we have seen elsewhere in POV-Ray make use of a
  7296. color_map statement to blend different colors together. Depending on how we
  7297. list the entries of the color map, we can fade gradually from one color to
  7298. the next, or have it abruptly make the transition from one to the next. In
  7299. fact, the color map is a powerful tool for customizing the various pigment
  7300. patterns, which requires a bit of practice to learn to use it correctly. And
  7301. all that's fine, when it's just individual colors we want to use. But what if
  7302. we could blend entire pigment patterns, normal patterns, or whole other
  7303. textures? Starting with POV-Ray 3, we can!
  7304.  
  7305. In order to experiment with some of the exciting new texturing options, let
  7306. us set up a basic scene file, into which we will be plugging the example
  7307. textures to experiment with later. So to begin, we set up the following basic
  7308. include files, a camera and a light source.
  7309.  
  7310.   #include "colors.inc"
  7311.   #include "textures.inc"
  7312.  
  7313.   camera {
  7314.     orthographic
  7315.     up <0, 5, 0>
  7316.     right <5, 0, 0>
  7317.     location <0, 0, -25>
  7318.     look_at <0, 0, 0>
  7319.   }
  7320.  
  7321.   light_source { <100, 100, -100> color White }
  7322.  
  7323.  
  7324. 4.9.1            Working With Pigment Maps
  7325.  
  7326. Starting with something simple, let's look at the pigment map. We must not
  7327. confuse this with a color map, as color maps can only take individual colors
  7328. as entries in the map, while pigment maps can use entire other pigment
  7329. patterns. To get a feel for these, let's begin by setting up a basic plane
  7330. with a simple pigment map. Now, in the following example, we are going to
  7331. declare each of the pigments we are going to use before we actually use them.
  7332. This isn't strictly necessary (we could put an entire pigment description in
  7333. each entry of the map) but it just makes the whole thing more readable.
  7334.  
  7335.   // simple Black on White checkboard... it's a classic
  7336.   #declare Pigment1 = pigment {
  7337.     checker color Black color White
  7338.     scale .1
  7339.   }
  7340.  
  7341.   // kind of a "psychedelic rings" effect
  7342.   #declare Pigment2 = pigment {
  7343.     wood
  7344.     color_map {
  7345.       [ 0.0 Red ]
  7346.       [ 0.3 Yellow ]
  7347.       [ 0.6 Green ]
  7348.       [ 1.0 Blue ]
  7349.     }
  7350.   }
  7351.  
  7352.   plane { -z, 0
  7353.     pigment {
  7354.       gradient x
  7355.       pigment_map {
  7356.         [ 0.0 Pigment1 ]
  7357.         [ 0.5 Pigment2 ]
  7358.         [ 1.0 Pigment1 ]
  7359.       }
  7360.     }
  7361.   }
  7362.  
  7363.  
  7364. Okay, what we have done here is very simple, and probably quite recognizable
  7365. if we have been working with color maps all along anyway. All we have done is
  7366. substituted a pigment map where a color map would normally go, and as the
  7367. entries in our map, we have referenced our declared pigments. When we render
  7368. this example, we see a pattern which fades back and forth between the classic
  7369. checkerboard, and those colorful rings. Because we fade from Pigment1 to
  7370. Pigment2 and then back again, we see a clear blending of the two patterns at
  7371. the transition points. We could just as easily get a sudden transition by
  7372. amending the map to read.
  7373.  
  7374.   pigment_map {
  7375.     [ 0.0 Pigment1 ]
  7376.     [ 0.5 Pigment1 ]
  7377.     [ 0.5 Pigment2 ]
  7378.     [ 1.0 Pigment2 ]
  7379.   }
  7380.  
  7381.  
  7382. 4.9.2            Working With Normal Maps
  7383.  
  7384. For our next example, we replace the plane in the scene with this one.
  7385.  
  7386.   plane { -z, 0
  7387.     pigment { White }
  7388.     normal {
  7389.       gradient x
  7390.       normal_map {
  7391.         [ 0.0 bumps 1 scale .1]
  7392.         [ 1.0 ripples 1 scale .1]
  7393.       }
  7394.     }
  7395.   }
  7396.  
  7397.  
  7398. First of all, we have chosen a solid white color to show off all bumping to
  7399. best effect. Secondly, we notice that our map blends smoothly from all bumps
  7400. at 0.0 to all ripples at 1.0, but because this is a default gradient, it
  7401. falls off abruptly back to bumps at the beginning of the next cycle. We
  7402. Render this and see just enough sharp transitions to clearly see where one
  7403. normal gives over to another, yet also an example of how two normal patterns
  7404. look while they are smoothly blending into one another.
  7405.  
  7406. The syntax is the same as we would expect. We just changed the type of map,
  7407. moved it into the normal block and supplied appropriate bump types. It is
  7408. important to remember that as of POV-Ray 3, all patterns that work with
  7409. pigments work as normals as well (and vice versa, of course) so we could just
  7410. as easily have blended from wood to granite, or any other pattern we like. We
  7411. experiment a bit and get a feel for what the different patterns look like.
  7412.  
  7413. After seeing how interesting the various normals look blended, we might like
  7414. to see them completely blended all the way through rather than this business
  7415. of fading from one to the next. Well, that is possible too, but we would be
  7416. getting ahead of ourselves. That is called the average function, and we will
  7417. return to it a little bit further down the page.
  7418.  
  7419. 4.9.3            Working With Texture Maps
  7420.  
  7421. We know how to blend colors, pigment patterns, and normals, and we are
  7422. probably thinking what about finishes? What about whole textures? Both of
  7423. these can be kind of covered under one topic. While there is no finish map
  7424. per se, there are texture maps, and we can easily adapt these to serve as
  7425. finish maps, simply by putting the same pigment and/or normal in each of the
  7426. texture entries of the map. Here is an example. We eliminate the declared
  7427. pigments we used before and the previous plane, and add the following.
  7428.  
  7429.   #declare Texture1 = texture {
  7430.     pigment { Grey }
  7431.     finish { reflection 1 }
  7432.   }
  7433.  
  7434.   #declare Texture2 = texture {
  7435.     pigment { Grey }
  7436.     finish { reflection 0 }
  7437.   }
  7438.  
  7439.   cylinder { <-2, 5, -2>, <-2, -5, -2>, 1
  7440.     pigment { Blue }
  7441.   }
  7442.  
  7443.   plane { -z, 0
  7444.     rotate y * 30
  7445.     texture {
  7446.       gradient y
  7447.       texture_map {
  7448.         [ 0.0 Texture1 ]
  7449.         [ 0.4 Texture1 ]
  7450.         [ 0.6 Texture2 ]
  7451.         [ 1.0 Texture2 ]
  7452.       }
  7453.       scale 2
  7454.     }
  7455.   }
  7456.  
  7457.  
  7458. Now, what have we done here? The background plane alternates vertically
  7459. between two textures, identical except for their finishes. When we render
  7460. this, the cylinder has a reflection part of the way down the plane, and then
  7461. stops reflecting, then begins and then stops again, in a gradient pattern
  7462. down the surface of the plane. With a little adaptation, this could be used
  7463. with any pattern, and in any number of creative ways, whether we just wanted
  7464. to give various parts of an object different finishes, as we are doing here,
  7465. or whole different textures altogether.
  7466.  
  7467. One might ask: if there is a texture map, why do we need pigment and normal
  7468. maps? Fair question. The answer: speed of calculation. If we use a texture
  7469. map, for every in-between point, POV-Ray must make multiple calculations for
  7470. each texture element, and then run a weighted average to produce the correct
  7471. value for that point. Using just a pigment map (or just a normal map)
  7472. decreases the overall number of calculations, and our texture renders a bit
  7473. faster in the bargain. As a rule of thumb: we use pigment or normal maps
  7474. where we can and only fall back on texture maps if we need the extra
  7475. flexibility.
  7476.  
  7477. 4.9.4            Working With List Textures
  7478.  
  7479. If we have followed the corresponding tutorials on simple pigments, we know
  7480. that there are three patterns called color list patterns, because rather than
  7481. using a color map, these simple but useful patterns take a list of colors
  7482. immediately following the pattern keyword. We're talking about checker,
  7483. hexagon, and, new to POV-Ray 3, the brick pattern.
  7484.  
  7485. Naturally they also work with whole pigments, normals, and entire textures,
  7486. just as the other patterns do above. The only difference is that we list
  7487. entries in the pattern (as we would do with individual colors) rather than
  7488. using a map of entries. Here is an example. We strike the plane and any
  7489. declared pigments we had left over in our last example, and add the following
  7490. to our basic file.
  7491.  
  7492.   #declare Pigment1 = pigment {
  7493.     hexagon
  7494.     color Yellow color Green color Grey
  7495.     scale .1
  7496.   }
  7497.  
  7498.   #declare Pigment2 = pigment {
  7499.     checker
  7500.     color Red color Blue
  7501.     scale .1
  7502.   }
  7503.  
  7504.   #declare Pigment3 = pigment {
  7505.     brick
  7506.     color White color Black
  7507.     rotate -90*x
  7508.     scale .1
  7509.   }
  7510.  
  7511.   box { -5, 5
  7512.     pigment {
  7513.       hexagon
  7514.       pigment {Pigment1}
  7515.       pigment {Pigment2}
  7516.       pigment {Pigment3}
  7517.       rotate 90*x
  7518.     }
  7519.   }
  7520.  
  7521.  
  7522. We begin by declaring an example of each of the color list patterns as
  7523. individual pigments. Then we use the hexagon pattern as a pigment list
  7524. pattern, simply feeding it a list of pigments rather than colors as we did
  7525. above. There are two rotate statements throughout this example, because
  7526. bricks are aligned along the z-direction, while hexagons align along the
  7527. y-direction, and we wanted everything to face toward the camera we originally
  7528. declared out in the -z-direction so we can really see the patterns within
  7529. patterns effect here.
  7530.  
  7531. Of course color list patterns used to be only for pigments, but as of POV-Ray
  7532. 3, everything that worked for pigments can now also be adapted for normals or
  7533. entire textures. A couple of quick examples might look like
  7534.  
  7535.   normal {
  7536.     brick
  7537.     normal { granite .1 }
  7538.     normal { bumps 1 scale .1 }
  7539.   }
  7540.  
  7541.  
  7542. or...
  7543.  
  7544.   texture {
  7545.     checker
  7546.     texture { Gold_Metal }
  7547.     texture { Silver_Metal }
  7548.   }
  7549.  
  7550.  
  7551. 4.9.5            What About Tiles?
  7552.  
  7553. In earlier versions of POV-Ray, there was a texture pattern called tiles. By
  7554. simply using a checker texture pattern (as we just saw above), we can achieve
  7555. the same thing as tiles used to do, so it is now obsolete. It is still
  7556. supported by POV-Ray 3 for backwards compatibility with old scene files, but
  7557. now is a good time to get in the habit of using a checker pattern instead.
  7558.  
  7559. 4.9.6            Average Function
  7560.  
  7561. Now things get interesting. Above, we began to see how pigments and normals
  7562. can fade from one to the other when we used them in maps. But how about if we
  7563. want a smooth blend of patterns all the way through? That is where a new
  7564. feature called average can come in very handy. Average works with pigment,
  7565. normal, and texture maps, although the syntax is a little bit different, and
  7566. when we are not expecting it, the change can be confusing. Here is a simple
  7567. example. We use our standard includes, camera and light source from above,
  7568. and enter the following object.
  7569.  
  7570.   plane { -z, 0
  7571.     pigment { White }
  7572.     normal {
  7573.       average
  7574.       normal_map {
  7575.         [ gradient x ]
  7576.         [ gradient y ]
  7577.       }
  7578.     }
  7579.   }
  7580.  
  7581.  
  7582. What we have done here is pretty self explanatory as soon as we render it. We
  7583. have combined a vertical with a horizontal gradient bump pattern, creating
  7584. crisscrossing gradients. Actually, the crisscrossing effect is a smooth blend
  7585. of gradient x with gradient y all the way across our plane. Now, what about
  7586. that syntax difference?
  7587.  
  7588. We see how our normal map has changed from earlier examples. The floating
  7589. point value to the lefthand side of each map entry has been removed. That
  7590. value usually helps in procedurally mapping each entry to the pattern we have
  7591. selected, but average is a smooth blend all the way through, not a pattern,
  7592. so it cannot use those values. In fact, including them may sometimes lead to
  7593. unexpected results, such as entries being lost or misrepresented in some way.
  7594. To ensure that we'll get the pattern blend we anticipate, we leave off the
  7595. floating point value.
  7596.  
  7597. 4.9.7            Working With Layered Textures
  7598.  
  7599. With the multitudinous colors, patterns, and options for creating complex
  7600. textures in POV-Ray, we can easily become deeply engrossed in mixing and
  7601. tweaking just the right textures to apply to our latest creations. But as we
  7602. go, sooner or later there is going to come that special texture. That texture
  7603. that is sort of like wood, only varnished, and with a kind of spotty yellow
  7604. streaking, and some vertical gray flecks, that looks like someone started
  7605. painting over it all, and then stopped, leaving part of the wood visible
  7606. through the paint.
  7607.  
  7608. Only... now what? How do we get all that into one texture? No pattern can do
  7609. that many things. Before we panic and say image map there is at least one
  7610. more option: layered textures.
  7611.  
  7612. With layered textures, we only need to specify a series of textures, one
  7613. after the other, all associated with the same object. Each texture we list
  7614. will be applied one on top of the other, from bottom to top in the order they
  7615. appear.
  7616.  
  7617. It is very important to note that we must have some degree of transparency
  7618. (filter or transmit) in the pigments of our upper textures, or the ones below
  7619. will get lost underneath. We won't receive a warning or an error -
  7620. technically it is legal to do this: it just doesn't make sense. It is like
  7621. spending hours sketching an elaborate image on a bare wall, then slapping a
  7622. solid white coat of latex paint over it.
  7623.  
  7624. Let's design a very simple object with a layered texture, and look at how it
  7625. works. We create a file called LAYTEX.POV and add the following lines.
  7626.  
  7627.   #include "colors.inc"
  7628.   #include "textures.inc"
  7629.  
  7630.   camera {
  7631.     location <0, 5, -30>
  7632.     look_at <0, 0, 0>
  7633.   }
  7634.  
  7635.   light_source { <-20, 30, -50> color White }
  7636.  
  7637.   plane { y, 0 pigment { checker color Green color Yellow  } }
  7638.  
  7639.   background { rgb <.7, .7, 1> }
  7640.  
  7641.   box { <-10, 0, -10>, <10, 10, 10>
  7642.     texture {
  7643.       Silver_Metal // a metal object ...
  7644.       normal {     // ... which has suffered a beating
  7645.         dents 2
  7646.         scale 1.5
  7647.       }
  7648.     } // (end of base texture)
  7649.  
  7650.     texture { // ... has some flecks of rust ...
  7651.       pigment {
  7652.         granite
  7653.         color_map {
  7654.           [0.0 rgb <.2, 0, 0> ]
  7655.           [0.2 color Brown ]
  7656.           [0.2 rgbt <1, 1, 1, 1> ]
  7657.           [1.0 rgbt <1, 1, 1, 1> ]
  7658.         }
  7659.         frequency 16
  7660.       }
  7661.     } // (end rust fleck texture)
  7662.  
  7663.     texture { // ... and some sooty black marks
  7664.       pigment {
  7665.         bozo
  7666.         color_map {
  7667.           [0.0 color Black ]
  7668.           [0.2 color rgbt <0, 0, 0, .5> ]
  7669.           [0.4 color rgbt <.5, .5, .5, .5> ]
  7670.           [0.5 color rgbt <1, 1, 1, 1> ]
  7671.           [1.0 color rgbt <1, 1, 1, 1> ]
  7672.         }
  7673.         scale 3
  7674.       }
  7675.     } // (end of sooty mark texture)
  7676.  
  7677.   } // (end of box declaration)
  7678.  
  7679.  
  7680. Whew. This gets complicated, so to make it easier to read, we have included
  7681. comments showing what we are doing and where various parts of the declaration
  7682. end (so we don't get lost in all those closing brackets!). To begin, we
  7683. created a simple box over the classic checkerboard floor, and give the
  7684. background sky a pale blue color. Now for the fun part...
  7685.  
  7686. To begin with we made the box use the Silver_Metal texture as declared in
  7687. textures.inc (for bonus points, look up textures.inc and see how this
  7688. standard texture was originally created sometime). To give it the start of
  7689. its abused state, we added the dents normal pattern, which creates the
  7690. illusion of some denting in the surface as if our mysterious metal box had
  7691. been knocked around quite a bit.
  7692.  
  7693. The flecks of rust are nothing but a fine grain granite pattern fading from
  7694. dark red to brown which then abruptly drops to fully transparent for the
  7695. majority of the color map. True, we could probably come up with a more
  7696. realistic pattern of rust using pigment maps to cluster rusty spots, but
  7697. pigment maps are a subject for another tutorial section, so let's skip that
  7698. just now.
  7699.  
  7700. Lastly, we have added a third texture to the pot. The randomly shifting bozo
  7701. texture gradually fades from blackened centers to semi-transparent medium
  7702. gray, and then ultimately to fully transparent for the latter half of its
  7703. color map. This gives us a look of sooty burn marks further marring the
  7704. surface of the metal box. The final result leaves our mysterious metal box
  7705. looking truly abused, using multiple texture patterns, one on top of the
  7706. other, to produce an effect that no single pattern could generate!
  7707.  
  7708. 4.9.7.1          Declaring Layered Textures
  7709.  
  7710. In the event we want to reuse a layered texture on several objects in our
  7711. scene, it is perfectly legal to declare a layered texture. We won't repeat
  7712. the whole texture from above, but the general format would be something like
  7713. this:
  7714.  
  7715.   #declare Abused_Metal =
  7716.     texture { /* insert your base texture here... */ }
  7717.     texture { /* and your rust flecks here... */ }
  7718.     texture { /* and of course, your sooty burn marks here */ }
  7719.  
  7720.  
  7721. POV-Ray has no problem spotting where the declaration ends, because the
  7722. textures follow one after the other with no objects or directives in between.
  7723. The layered texture to be declared will be assumed to continue until it finds
  7724. something other than another texture, so any number of layers can be added in
  7725. to a declaration in this fashion.
  7726.  
  7727. One final word about layered textures: whatever layered texture we create,
  7728. whether declared or not, we must not leave off the texture wrapper. In
  7729. conventional single textures a common shorthand is to have just a pigment, or
  7730. just a pigment and finish, or just a normal, or whatever, and leave them
  7731. outside of a texture statement. This shorthand does not extend to layered
  7732. textures. As far as POV-Ray is concerned we can layer entire textures, but
  7733. not individual pieces of textures. For example
  7734.  
  7735.   #declare Bad_Texture =
  7736.     texture { /* insert your base texture here... */ }
  7737.     pigment { Red filter .5 }
  7738.     normal { bumps 1 }
  7739.  
  7740.  
  7741. will not work. The pigment and the normal are just floating there without
  7742. being part of any particular texture. Inside an object, with just a single
  7743. texture, we can do this sort of thing, but with layered textures, we would
  7744. just generate an error whether inside the object or in a declaration.
  7745.  
  7746. 4.9.7.2          Another Layered Textures Example
  7747.  
  7748. To further explain how layered textures work another example is described in
  7749. detail. A tablecloth is created to be used in a picnic scene. Since a simple
  7750. red and white checked cloth looks entirely too new, too flat, and too much
  7751. like a tiled floor, layered textures are used to stain the cloth.
  7752.  
  7753. We're going to create a scene containing four boxes. The first box has that
  7754. plain red and white texture we started with in our picnic scene, the second
  7755. adds a layer meant to realistically fade the cloth, the third adds some wine
  7756. stains, and the final box adds a few wrinkles (not another layer, but we must
  7757. note when and where adding changes to the surface normal have an effect in
  7758. layered textures).
  7759.  
  7760. We start by placing a camera, some lights, and the first box. At this stage,
  7761. the texture is plain tiling, not layered. See file layered1.pov.
  7762.  
  7763.   #include "colors.inc"
  7764.  
  7765.   camera {
  7766.     location <0, 0, -6>
  7767.     look_at <0, 0, 0>
  7768.   }
  7769.  
  7770.   light_source { <-20, 30, -100> color White }
  7771.   light_source { <10, 30, -10> color White }
  7772.   light_source { <0, 30, 10> color White }
  7773.  
  7774.   #declare PLAIN_TEXTURE =
  7775.     // red/white check
  7776.     texture {
  7777.       pigment {
  7778.         checker
  7779.         color rgb<1.000, 0.000, 0.000>
  7780.         color rgb<1.000, 1.000, 1.000>
  7781.         scale <0.2500, 0.2500, 0.2500>
  7782.       }
  7783.     }
  7784.  
  7785.   // plain red/white check box
  7786.  
  7787.   box { <-1, -1, -1>, <1, 1, 1>
  7788.     texture {
  7789.       PLAIN_TEXTURE
  7790.     }
  7791.     translate  <-1.5, 1.2, 0>
  7792.   }
  7793.  
  7794.  
  7795. We render this scene. It is not particularly interesting, isn't it? That is
  7796. why we will use some layered textures to make it more interesting.
  7797.  
  7798. First, we add a layer of two different, partially transparent greys. We tile
  7799. them as we had tiled the red and white colors, but we add some turbulence to
  7800. make the fading more realistic. We add following box to the previous scene
  7801. and re-render (see file layered2.pov).
  7802.  
  7803.   #declare FADED_TEXTURE =
  7804.     // red/white check texture
  7805.     texture {
  7806.       pigment {
  7807.         checker
  7808.         color rgb<0.920, 0.000, 0.000>
  7809.         color rgb<1.000, 1.000, 1.000>
  7810.         scale <0.2500, 0.2500, 0.2500>
  7811.       }
  7812.     }
  7813.     // greys to fade red/white
  7814.     texture {
  7815.       pigment {
  7816.         checker
  7817.         color rgbf<0.632, 0.612, 0.688, 0.698>
  7818.         color rgbf<0.420, 0.459, 0.520, 0.953>
  7819.         turbulence 0.500
  7820.         scale <0.2500, 0.2500, 0.2500>
  7821.       }
  7822.     }
  7823.  
  7824.   // faded red/white check box
  7825.  
  7826.   box { <-1, -1, -1>, <1, 1, 1>
  7827.     texture {
  7828.       FADED_TEXTURE
  7829.     }
  7830.     translate  <1.5, 1.2, 0>
  7831.   }
  7832.  
  7833.  
  7834. Even though it is a subtle difference, the red and white checks no longer
  7835. look quite so new.
  7836.  
  7837. Since there is a bottle of wine in the picnic scene, we thought it might be a
  7838. nice touch to add a stain or two. While this effect can almost be achieved by
  7839. placing a flattened blob on the cloth, what we really end up with is a spill
  7840. effect, not a stain. Thus it is time to add another layer.
  7841.  
  7842. Again, we add another box to the scene we already have scripted and re-render
  7843. (see file layered3.pov).
  7844.  
  7845.   #declare STAINED_TEXTURE =
  7846.     // red/white check
  7847.     texture {
  7848.       pigment {
  7849.         checker
  7850.         color rgb<0.920, 0.000, 0.000>
  7851.         color rgb<1.000, 1.000, 1.000>
  7852.         scale <0.2500, 0.2500, 0.2500>
  7853.       }
  7854.     }
  7855.     // greys to fade check
  7856.     texture {
  7857.       pigment {
  7858.         checker
  7859.         color rgbf<0.634, 0.612, 0.688, 0.698>
  7860.         color rgbf<0.421, 0.463, 0.518, 0.953>
  7861.         turbulence 0.500
  7862.         scale <0.2500, 0.2500, 0.2500>
  7863.       }
  7864.     }
  7865.     // wine stain
  7866.     texture {
  7867.       pigment {
  7868.         spotted
  7869.         color_map {
  7870.           [ 0.000  color rgb<0.483, 0.165, 0.165> ]
  7871.           [ 0.329  color rgbf<1.000, 1.000, 1.000, 1.000> ]
  7872.           [ 0.734  color rgbf<1.000, 1.000, 1.000, 1.000> ]
  7873.  
  7874.           [ 1.000  color rgb<0.483, 0.165, 0.165> ]
  7875.         }
  7876.         turbulence 0.500
  7877.         frequency 1.500
  7878.       }
  7879.     }
  7880.  
  7881.   // stained box
  7882.  
  7883.   box { <-1, -1, -1>, <1, 1, 1>
  7884.     texture {
  7885.       STAINED_TEXTURE
  7886.     }
  7887.     translate  <-1.5, -1.2, 0>
  7888.   }
  7889.  
  7890.  
  7891. Now there's a tablecloth texture with personality.
  7892.  
  7893. Another touch we want to add to the cloth are some wrinkles as if the cloth
  7894. had been rumpled. This is not another texture layer, but when working with
  7895. layered textures, we must keep in mind that changes to the surface normal
  7896. must be included in the uppermost layer of the texture. Changes to lower
  7897. layers have no effect on the final product (no matter how transparent the
  7898. upper layers are).
  7899.  
  7900. We add this final box to the script and re-render (see file layered4.pov)
  7901.  
  7902.   #declare WRINKLED_TEXTURE =
  7903.     // red and white check
  7904.     texture {
  7905.       pigment {
  7906.         checker
  7907.         color rgb<0.920, 0.000, 0.000>
  7908.         color rgb<1.000, 1.000, 1.000>
  7909.         scale <0.2500, 0.2500, 0.2500>
  7910.       }
  7911.     }
  7912.     // greys to "fade" checks
  7913.     texture {
  7914.       pigment {
  7915.         checker
  7916.         color rgbf<0.632, 0.612, 0.688, 0.698>
  7917.         color rgbf<0.420, 0.459, 0.520, 0.953>
  7918.         turbulence 0.500
  7919.         scale <0.2500, 0.2500, 0.2500>
  7920.       }
  7921.     }
  7922.     // the wine stains
  7923.     texture {
  7924.       pigment {
  7925.         spotted
  7926.         color_map {
  7927.           [ 0.000  color rgb<0.483, 0.165, 0.165> ]
  7928.           [ 0.329  color rgbf<1.000, 1.000, 1.000, 1.000> ]
  7929.           [ 0.734  color rgbf<1.000, 1.000, 1.000, 1.000> ]
  7930.           [ 1.000  color rgb<0.483, 0.165, 0.165> ]
  7931.         }
  7932.         turbulence 0.500
  7933.         frequency 1.500
  7934.       }
  7935.       normal {
  7936.         wrinkles 5.0000
  7937.       }
  7938.     }
  7939.  
  7940.   // wrinkled box
  7941.  
  7942.   box { <-1, -1, -1>, <1, 1, 1>
  7943.     texture {
  7944.       WRINKLED_TEXTURE
  7945.     }
  7946.     translate  <1.5, -1.2, 0>
  7947.   }
  7948.  
  7949.  
  7950. Well, this may not be the tablecloth we want at any picnic we're attending,
  7951. but if we compare the final box to the first, we see just how much depth,
  7952. dimension, and personality is possible just by the use of creative texturing.
  7953.  
  7954.  
  7955. One final note: the comments concerning the surface normal do not hold true
  7956. for finishes. If a lower layer contains a specular finish and an upper layer
  7957. does not, any place where the upper layer is transparent, the specular will
  7958. show through.
  7959.  
  7960. 4.9.8            When All Else Fails: Material Maps
  7961.  
  7962. We have some pretty powerful texturing tools at our disposal, but what if we
  7963. want a more free form arrangement of complex textures? Well, just as image
  7964. maps do for pigments, and bump maps do for normals, whole textures can be
  7965. mapped using a material map, should the need arise.
  7966.  
  7967. Just as with image maps and bump maps, we need a source image in bitmapped
  7968. format which will be called by POV-Ray to serve as the map of where the
  7969. individual textures will go, but this time, we need to specify what texture
  7970. will be associated with which palette index. To make such an image, we can
  7971. use a paint program which allows us to select colors by their palette index
  7972. number (the actual color is irrelevant, since it is only a map to tell
  7973. POV-Ray what texture will go at that location). Now, if we have the complete
  7974. package that comes with POV-Ray, we have in our include files an image called
  7975. povmap.gif which is a bitmapped image that uses only the first four palette
  7976. indices to create a bordered square with the words Persistance of Vision in
  7977. it. This will do just fine as a sample map for the following example. Using
  7978. our same include files, the camera and light source, we enter the follow
  7979. object.
  7980.  
  7981.   plane { -z, 0
  7982.     texture {
  7983.       material_map {
  7984.         gif "povmap.gif"
  7985.         interpolate 2
  7986.         once
  7987.         texture { PinkAlabaster }          // the inner border
  7988.         texture { pigment { DMFDarkOak } } // outer border
  7989.         texture { Gold_Metal }             // lettering
  7990.         texture { Chrome_Metal }           // the window panel
  7991.       }
  7992.       translate <-0.5, -0.5, 0>
  7993.       scale 5
  7994.     }
  7995.   }
  7996.  
  7997.  
  7998. The position of the light source and the lack of foreground objects to be
  7999. reflected do not show these textures off to their best advantage. But at
  8000. least we can see how the process works. The textures have simply been placed
  8001. according to the location of pixels of a particular palette index. By using
  8002. the once keyword (to keep it from tiling), and translating and scaling our
  8003. map to match the camera we have been using, we get to see the whole thing
  8004. laid out for us.
  8005.  
  8006. Of course, that is just with palette mapped image formats, such as GIF and
  8007. certain flavors of PNG. Material maps can also use non-paletted formats, such
  8008. as the TGA files that POV-Ray itself outputs. That leads to an interesting
  8009. consquence: We can use POV-Ray to produce source maps for POV-Ray! Before we
  8010. wrap up with some of the limitations of special textures, let's do one more
  8011. thing with material maps, to show how POV-Ray can make its own source maps.
  8012.  
  8013. To begin with, if using an non-paletted image, POV-Ray looks at the 8 bit red
  8014. component of the pixel's color (which will be a value from 0 to 255) to
  8015. determine which texture from the list to use. So to create a source map, we
  8016. need to control very precisely what the red value of a given pixel will be.
  8017. We can do this by
  8018.  
  8019.   1.)Using an rgb statement to choose our color such as rgb <x/255, 0, 0>,
  8020.   2.)Use no light sources and apply a finish of finish { ambient 1 } to all
  8021.      objects, to ensure that highlighting and shadowing will not interfere.
  8022.  
  8023.  
  8024. Confused? Alright, here is an example, which will generate a map very much
  8025. like povmap.gif which we used earlier, except in TGA file format. We notice
  8026. that we have given the pigments blue and green components too. POV-Ray will
  8027. ignore that in our final map, so this is really for us humans, whose unaided
  8028. eyes cannot tell the difference between red variances of 0 to 4/255ths.
  8029. Without those blue and green variances, our map would look to our eyes like a
  8030. solid black screen. That may be a great way to send secret messages using
  8031. POV-Ray (plug it into a material map to decode) but it is no use if we want
  8032. to see what our source map looks like to make sure we have what we expected
  8033. to.
  8034.  
  8035. We render the following code, and name the resulting file povmap.tga.
  8036.  
  8037.   camera {
  8038.     orthographic
  8039.     up <0, 5, 0>
  8040.     right <5, 0, 0>
  8041.     location <0, 0, -25>
  8042.     look_at <0, 0, 0>
  8043.   }
  8044.  
  8045.   plane { -z, 0
  8046.     pigment { rgb <1/255, 0, 0.5> }
  8047.     finish { ambient 1 }
  8048.   }
  8049.  
  8050.   box { <-2.3, -1.8, -0.2>, <2.3, 1.8, -0.2>
  8051.     pigment { rgb <0/255, 0, 1> }
  8052.     finish { ambient 1 }
  8053.   }
  8054.  
  8055.   box { <-1.95, -1.3, -0.4>, <1.95, 1.3, -0.3>
  8056.     pigment { rgb <2/255, 0.5, 0.5> }
  8057.     finish { ambient 1 }
  8058.   }
  8059.  
  8060.   text { ttf "crystal.ttf", "The vision", 0.1, 0
  8061.     scale <0.7, 1, 1>
  8062.     translate <-1.8, 0.25, -0.5>
  8063.     pigment { rgb <3/255, 1, 1> }
  8064.     finish { ambient 1 }
  8065.   }
  8066.  
  8067.   text { ttf "crystal.ttf", "Persists!", 0.1, 0
  8068.     scale <0.7, 1, 1>
  8069.     translate <-1.5, -1, -0.5>
  8070.     pigment { rgb <3/255, 1, 1> }
  8071.     finish { ambient 1 }
  8072.   }
  8073.  
  8074.  
  8075. All we have to do is modify our last material map example by changing the
  8076. material map from GIF to TGA and modifying the filename. When we render using
  8077. the new map, the result is extremely similar to the pallette mapped GIF we
  8078. used before, except that we didn't have to use an external paint program to
  8079. generate our source: POV-Ray did it all!
  8080.  
  8081. 4.9.9            Limitations Of Special Textures
  8082.  
  8083. There are a couple limitations to all of the special textures we have seen
  8084. (from textures, pigment and normal maps through material maps). First, if we
  8085. have used the default directive to set the default texture for all items in
  8086. our scene, it will not accept any of the special textures discussed here.
  8087. This is really quite minor, since we can always declare such a texture and
  8088. apply it individually to all objects. It doesn't actually prevent us from
  8089. doing anything we couldn't otherwise do.
  8090.  
  8091. The other is more limiting, but as we will shortly see, can be worked around
  8092. quite easily. If we have worked with layered textures, we have already seen
  8093. how we can pile multiple texture patterns on top of one another (as long as
  8094. one texture has transparency in it). This very useful technique has a problem
  8095. incorporating the special textures we have just seen as a layer. But there is
  8096. an answer!
  8097.  
  8098. For example, say we have a layered texture called Speckled_Metal, which
  8099. produces a silver metallic surface, and then puts tiny specks of rust all
  8100. over it. Then we decide, for a really rusty look, we want to create patches
  8101. of concentrated rust, randomly over the surface. The obvious approach is to
  8102. create a special texture pattern, with transparency to use as the top layer.
  8103. But of course, as we have seen, we wouldn't be able to use that texture
  8104. pattern as a layer. We would just generate an error message. The solution is
  8105. to turn the problem inside out, and make our layered texture part of the
  8106. texture pattern instead, like this
  8107.  
  8108.   // This part declares a pigment for use
  8109.   // in the rust patch texture pattern
  8110.   #declare Rusty = pigment {
  8111.     granite
  8112.     color_map {
  8113.       [ 0 rgb <0.2, 0, 0> ]
  8114.       [ 1 Brown ]
  8115.     }
  8116.     frequency 20
  8117.   }
  8118.  
  8119.   // And this part applies it
  8120.   // Notice that our original layered texture
  8121.   // "Speckled_Metal" is now part of the map
  8122.   #declare Rust_Patches = texture {
  8123.     bozo
  8124.     texture_map {
  8125.       [ 0.0  pigment {Rusty} ]
  8126.       [ 0.75 Speckled_Metal ]
  8127.       [ 1.0  Speckled_Metal ]
  8128.     }
  8129.   }
  8130.  
  8131.  
  8132. And the ultimate effect is the same as if we had layered the rust patches on
  8133. to the speckled metal anyway.
  8134.  
  8135. With the full array of patterns, pigments, normals, finishes, layered and
  8136. special textures, there is now practically nothing we cannot create in the
  8137. way of amazing textures. An almost infinite number of new possibilities are
  8138. just waiting to be created!
  8139.  
  8140. 4.10             Using Atmospheric Effects
  8141.  
  8142. POV-Ray offers a variety of atmospheric effects, i. e. features that affect
  8143. the background of the scene or the air by which everything is surrounded.
  8144.  
  8145. It is easy to assign a simple color or a complex color pattern to a virtual
  8146. sky sphere. You can create anything from a cloud free, blue summer sky to a
  8147. stormy, heavy clouded sky. Even starfields can easily be created.
  8148.  
  8149. You can use different kinds of fog to create foggy scenes. Multiple fog
  8150. layers of different colors can add an eerie touch to your scene.
  8151.  
  8152. A much more realistic effect can be created by using an atmosphere, a
  8153. constant fog that interacts with the light coming from light sources. Beams
  8154. of light become visible and objects will cast shadows into the fog.
  8155.  
  8156.  
  8157. 4.10.1           The Background
  8158.  
  8159. The background feature is used to assign a color to all rays that don't hit
  8160. any object. This is done in the following way.
  8161.  
  8162.   camera {
  8163.     location <0, 0, -10>
  8164.     look_at <0, 0, 0>
  8165.   }
  8166.  
  8167.   background { color rgb <0.2, 0.2, 0.3> }
  8168.  
  8169.   sphere { 0, 1
  8170.     pigment { color rgb <0.8, 0.5, 0.2> }
  8171.   }
  8172.  
  8173.  
  8174. The background color will be visible if a sky sphere is used and if some
  8175. translucency remains after all sky sphere pigment layers are processed.
  8176.  
  8177. 4.10.2           The Sky Sphere
  8178.  
  8179. The sky sphere can be used to easily create a cloud covered sky, a nightly
  8180. star sky or whatever sky you have in mind.
  8181.  
  8182. In the following examples we'll start with a very simple sky sphere that will
  8183. get more and more complex as we add new features to it.
  8184.  
  8185. 4.10.2.1         Creating a Sky with a Color Gradient
  8186.  
  8187. Beside the single color sky sphere that is covered with the background
  8188. feature the simplest sky sphere is a color gradient.
  8189.  
  8190. You may have noticed that the color of the sky varies with the angle to the
  8191. earth's surface normal. If you look straight up the sky normally has a much
  8192. deeper blue than it has at the horizon.
  8193.  
  8194. We want to model this effect using the sky sphere as shown in the scene below
  8195. (skysph1.pov).
  8196.  
  8197.   #include "colors.inc"
  8198.  
  8199.   camera {
  8200.     location <0, 1, -4>
  8201.     look_at <0, 2, 0>
  8202.     angle 80
  8203.   }
  8204.  
  8205.   light_source { <10, 10, -10> White }
  8206.  
  8207.   sphere { 2*y, 1
  8208.     pigment { color rgb <1, 1, 1> }
  8209.     finish { ambient 0.2 diffuse 0 reflection 0.6 }
  8210.   }
  8211.  
  8212.   sky_sphere {
  8213.     pigment {
  8214.       gradient y
  8215.       color_map {
  8216.         [0 color Red]
  8217.         [1 color Blue]
  8218.       }
  8219.       scale 2
  8220.       translate -1
  8221.     }
  8222.   }
  8223.  
  8224.  
  8225. The interesting part is the sky sphere statement. It contains a pigment that
  8226. describe the look of the sky sphere. We want to create a color gradient along
  8227. the viewing angle measured against the earth's surface normal. Since the ray
  8228. direction vector is used to calculate the pigment colors we have to use the
  8229. y-gradient.
  8230.  
  8231. The scale and translate transformation are used to map the points derived
  8232. from the direction vector to the right range. Without those transformations
  8233. the pattern would be repeated twice on the sky sphere. The scale statement is
  8234. used to avoid the repetition and the translate -1 statement moves the color
  8235. at index zero to the bottom of the sky sphere (that's the point of the sky
  8236. sphere you'll see if you look straight down).
  8237.  
  8238. After this transformation the color entry at position 0 will be at the bottom
  8239. of the sky sphere, i. e. below us, and the color at position 1 will be at the
  8240. top, i. e. above us.
  8241.  
  8242. The colors for all other positions are interpolated between those two colors
  8243. as you can see in the resulting image.
  8244.  
  8245. A simple gradient sky sphere.
  8246.  
  8247. If you want to start one of the colors at a specific angle you'll first have
  8248. to convert the angle to a color map index. This is done by using the formula
  8249.  
  8250.   color_map_index = (1 - cos(angle)) / 2
  8251.  
  8252.  
  8253. where the angle is measured against the negated earth's surface normal. This
  8254. is the surface normal pointing towards the center of the earth. An angle of 0
  8255. degrees describes the point below us while an angle of 180 degrees represents
  8256. the zenith.
  8257.  
  8258. In POV-Ray you first have to convert the degree value to radian values as it
  8259. is shown in the following example.
  8260.  
  8261.   sky_sphere {
  8262.     pigment {
  8263.       gradient y
  8264.       color_map {
  8265.         [(1-cos(radians( 30)))/2 color Red]
  8266.         [(1-cos(radians(120)))/2 color Blue]
  8267.       }
  8268.       scale 2
  8269.       translate -1
  8270.     }
  8271.   }
  8272.  
  8273.  
  8274. This scene uses a color gradient that starts with a red color at 30 degrees
  8275. and blends into the blue color at 120 degrees. Below 30 degrees everything is
  8276. red while above 120 degrees all is blue.
  8277.  
  8278. 4.10.2.2         Adding the Sun
  8279.  
  8280. In the following example we will create a sky with a red sun surrounded by a
  8281. red color halo that blends into the dark blue night sky. We'll do this using
  8282. only the sky sphere feature.
  8283.  
  8284. The sky sphere we use is shown below. A ground plane is also added for
  8285. greater realism (skysph2.pov).
  8286.  
  8287.   sky_sphere {
  8288.     pigment {
  8289.       gradient y
  8290.       color_map {
  8291.         [0.000 0.002 color rgb <1.0, 0.2, 0.0>
  8292.                      color rgb <1.0, 0.2, 0.0>]
  8293.         [0.002 0.200 color rgb <0.8, 0.1, 0.0>
  8294.                      color rgb <0.2, 0.2, 0.3>]
  8295.       }
  8296.       scale 2
  8297.       translate -1
  8298.     }
  8299.     rotate -135*x
  8300.   }
  8301.  
  8302.   plane { y, 0
  8303.     pigment { color Green }
  8304.     finish { ambient .3 diffuse .7 }
  8305.   }
  8306.  
  8307.  
  8308. The gradient pattern and the transformation inside the pigment are the same
  8309. as in the example in the previous section.
  8310.  
  8311. The color map consists of three colors. A bright, slightly yellowish red that
  8312. is used for the sun, a darker red for the halo and a dark blue for the night
  8313. sky. The sun's color covers only a very small portion of the sky sphere
  8314. because we don't want the sun to become too big. The color is used at the
  8315. color map values 0.000 and 0.002 to get a sharp contrast at value 0.002 (we
  8316. don't want the sun to blend into the sky). The darker red color used for the
  8317. halo blends into the dark blue sky color from value 0.002 to 0.200. All
  8318. values above 0.200 will reveal the dark blue sky.
  8319.  
  8320. The rotate -135*x statement is used to rotate the sun and the complete sky
  8321. sphere to its final position. Without this rotation the sun would be at 0
  8322. degrees, i.e. right below us.
  8323.  
  8324. A red sun descends into the night.
  8325.  
  8326. Looking at the resulting image you'll see what impressive effects you can
  8327. achieve with the sky sphere.
  8328.  
  8329. 4.10.2.3         Adding Some Clouds
  8330.  
  8331. To further improve our image we want to add some clouds by adding a second
  8332. pigment. This new pigment uses the bozo pattern to create some nice clouds.
  8333. Since it lays on top of the other pigment it needs some translucent colors in
  8334. the color map (look at entries 0.5 to 1.0).
  8335.  
  8336.   sky_sphere {
  8337.     pigment {
  8338.       gradient y
  8339.       color_map {
  8340.         [0.000 0.002 color rgb <1.0, 0.2, 0.0>
  8341.                      color rgb <1.0, 0.2, 0.0>]
  8342.         [0.002 0.200 color rgb <0.8, 0.1, 0.0>
  8343.                      color rgb <0.2, 0.2, 0.3>]
  8344.       }
  8345.       scale 2
  8346.       translate -1
  8347.     }
  8348.     pigment {
  8349.       bozo
  8350.       turbulence 0.65
  8351.       octaves 6
  8352.       omega 0.7
  8353.       lambda 2
  8354.       color_map {
  8355.           [0.0 0.1 color rgb <0.85, 0.85, 0.85>
  8356.                    color rgb <0.75, 0.75, 0.75>]
  8357.           [0.1 0.5 color rgb <0.75, 0.75, 0.75>
  8358.                    color rgbt <1, 1, 1, 1>]
  8359.           [0.5 1.0 color rgbt <1, 1, 1, 1>
  8360.                    color rgbt <1, 1, 1, 1>]
  8361.       }
  8362.       scale <0.2, 0.5, 0.2>
  8363.     }
  8364.     rotate -135*x
  8365.   }
  8366.  
  8367.  
  8368. A cloudy sky with a setting sun.
  8369.  
  8370. The sky sphere has one drawback as you might notice when looking at the final
  8371. image (skysph3.pov). The sun doesn't emit any light and the clouds will not
  8372. cast any shadows. If you want to have clouds that cast shadows you'll have to
  8373. use a real, large sphere with an appropriate texture and a light source
  8374. somewhere outside the sphere.
  8375.  
  8376. 4.10.3           The Fog
  8377.  
  8378. You can use the fog feature to add fog of two different types to your scene:
  8379. constant fog and ground fog. The constant fog has a constant density
  8380. everywhere while the ground fog's density decreases as you move upwards.
  8381.  
  8382.  
  8383. 4.10.3.1         A Constant Fog
  8384.  
  8385. The simplest fog type is the constant fog that has a constant density in all
  8386. locations. It is specified by a distance keyword which actually describes the
  8387. fog's density and a fog color.
  8388.  
  8389. The distance value determines the distance at which 36.8% of the background
  8390. are still visible (for a more detailed explanation of how the fog is
  8391. calculated read the reference section "Fog").
  8392.  
  8393. The fog color can be used to create anything from a pure white to a red,
  8394. blood-colored fog. You can also use a black fog to simulate the effect of a
  8395. limited range of vision.
  8396.  
  8397. The following example will show you how to add fog to a simple scene
  8398. (fog1.pov).
  8399.  
  8400.   #include "colors.inc"
  8401.  
  8402.   camera {
  8403.     location  <0, 20, -100>
  8404.   }
  8405.  
  8406.   background { colour SkyBlue }
  8407.  
  8408.   plane { y, -10
  8409.     pigment {
  8410.       checker colour Yellow colour Green
  8411.       scale 20
  8412.     }
  8413.   }
  8414.  
  8415.   sphere { <0, 25, 0>, 40
  8416.     pigment { Red }
  8417.     finish { phong 1.0 phong_size 20 }
  8418.   }
  8419.  
  8420.   sphere { <-100, 150, 200>,  20
  8421.     pigment { Green }
  8422.     finish { phong 1.0 phong_size 20 }
  8423.   }
  8424.  
  8425.   sphere { <100, 25, 100>, 30
  8426.     pigment { Blue }
  8427.     finish { phong 1.0 phong_size 20 }
  8428.   }
  8429.  
  8430.   light_source { <100, 120, 40> colour White}
  8431.  
  8432.   fog {
  8433.     distance 150
  8434.     colour rgb<0.3, 0.5, 0.2>
  8435.   }
  8436.  
  8437.  
  8438. A foggy scene.
  8439.  
  8440. According to their distance the spheres in this scene more or less vanish in
  8441. the greenish fog we used, as does the checkerboard plane.
  8442.  
  8443. 4.10.3.2         Setting a Minimum Translucency
  8444.  
  8445. If you want to make sure that the background does not completely vanish in
  8446. the fog you can set the transmittance channel of the fog's color to the
  8447. amount of background you always want to be visible.
  8448.  
  8449. Using as transmittance value of 0.2 as in
  8450.  
  8451.   fog {
  8452.     distance 150
  8453.     colour rgbt<0.3, 0.5, 0.2, 0.2>
  8454.   }
  8455.  
  8456.  
  8457. the fog's translucency never drops below 20% as you can see in the resulting
  8458. image (fog2.pov).
  8459.  
  8460. Adding a translucency threshold you make sure that the background does not
  8461. vanish.
  8462.  
  8463. 4.10.3.3         Creating a Filtering Fog
  8464.  
  8465. The greenish fog we have used so far doesn't filter the light passing through
  8466. it. All it does is to diminish the light's intensity. We can change this by
  8467. using a non-zero filter channel in the fog's color (fog3.pov).
  8468.  
  8469.   fog {
  8470.     distance 150
  8471.     colour rgbf<0.3, 0.5, 0.2, 1.0>
  8472.   }
  8473.  
  8474.  
  8475. The filter value determines the amount of light that is filtered by the fog.
  8476. In our example 100% of the light passing through the fog will be filtered by
  8477. the fog. If we had used a value of 0.7 only 70% of the light would have been
  8478. filtered. The remaining 30% would have passed unfiltered.
  8479.  
  8480. A filtering fog.
  8481.  
  8482. You'll notice that the intensity of the objects in the fog is not only
  8483. diminished due to the fog's color but that the colors are actually influenced
  8484. by the fog. The red and especially the blue sphere got a green hue.
  8485.  
  8486. 4.10.3.4         Adding Some Turbulence to the Fog
  8487.  
  8488. In order to make our somewhat boring fog a little bit more interesting we can
  8489. add some turbulence, making it look like it had a non-constant density
  8490. (fog4.pov).
  8491.  
  8492.   fog {
  8493.     distance 150
  8494.     colour rgbf<0.3, 0.5, 0.2, 1.0>
  8495.     turbulence 0.2
  8496.     turb_depth 0.3
  8497.   }
  8498.  
  8499.  
  8500. Adding some turbulence makes the fog more interesting.
  8501.  
  8502. The turbulence keyword is used to specify the amount of turbulence used while
  8503. the turb_depth value is used to move the point at which the turbulence value
  8504. is calculated along the viewing ray. Values near zero move the point to the
  8505. viewer while values near one move it to the intersection point (the default
  8506. value is 0.5). This parameter can be used to avoid noise that may appear in
  8507. the fog due to the turbulence (this normally happens at very far away
  8508. intersection points, especially if no intersection occurs, i. e. the
  8509. background is hit). If this happens just lower the turb_depth value until the
  8510. noise vanishes.
  8511.  
  8512. You should keep in mind that the actual density of the fog does not change.
  8513. Only the distance-based attenuation value of the fog is modified by the
  8514. turbulence value at a point along the viewing ray.
  8515.  
  8516. 4.10.3.5         Using Ground Fog
  8517.  
  8518. The much more interesting and flexible fog type is the ground fog, which is
  8519. selected with the fog_type statement. It's appearance is described with the
  8520. fog_offset and fog_alt keywords. The fog_offset specifies the height, i. e. y
  8521. value, below which the fog has a constant density of one. The fog_alt keyword
  8522. determines how fast the density of the fog will approach zero as one moves
  8523. along the y axis. At a height of fog_offset+fog_alt the fog will have a
  8524. density of 25%.
  8525.  
  8526. The following example (fog5.pov) uses a ground fog which has a constant
  8527. density below y=25 (the center of the red sphere) and quickly falls off for
  8528. increasing altitudes.
  8529.  
  8530.   fog {
  8531.     distance 150
  8532.     colour rgbf<0.3, 0.5, 0.2, 1.0>
  8533.     fog_type 2
  8534.     fog_offset 25
  8535.     fog_alt 1
  8536.   }
  8537.  
  8538.  
  8539. 4.10.3.6         Using Multiple Layers of Fog
  8540.  
  8541. It is possible to use several layers of fog by using more than one fog
  8542. statement in your scene file. This is quite useful if you want to get nice
  8543. effects using turbulent ground fogs. You could add up several, differently
  8544. colored fogs to create an eerie scene for example.
  8545.  
  8546. Just try the following example (fog6.pov).
  8547.  
  8548.   fog {
  8549.     distance 150
  8550.     colour rgb<0.3, 0.5, 0.2>
  8551.     fog_type 2
  8552.     fog_offset 25
  8553.     fog_alt 1
  8554.     turbulence 0.1
  8555.     turb_depth 0.2
  8556.   }
  8557.  
  8558.   fog {
  8559.     distance 150
  8560.     colour rgb<0.5, 0.1, 0.1>
  8561.     fog_type 2
  8562.     fog_offset 15
  8563.     fog_alt 4
  8564.     turbulence 0.2
  8565.     turb_depth 0.2
  8566.   }
  8567.  
  8568.   fog {
  8569.     distance 150
  8570.     colour rgb<0.1, 0.1, 0.6>
  8571.     fog_type 2
  8572.     fog_offset 10
  8573.     fog_alt 2
  8574.   }
  8575.  
  8576.  
  8577. Quite nice results can be achieved using multiple layers of fog.
  8578.  
  8579. You can combine constant density fogs, ground fogs, filtering fogs,
  8580. non-filtering fogs, fogs with a translucency threshold, etc.
  8581.  
  8582. 4.10.3.7         Fog and Hollow Objects
  8583.  
  8584. Whenever you use the fog feature and the camera is inside a non-hollow object
  8585. you won't get any fog effects. For a detailed explanation why this happens
  8586. see "Empty and Solid Objects".
  8587.  
  8588. In order to avoid this problem you have to make all those objects hollow by
  8589. either making sure the camera is outside these objects (using the inverse
  8590. keyword) or by adding the hollow to them (which is much easier).
  8591.  
  8592. 4.10.4           The Atmosphere
  8593.  
  8594. Important notice: The atmosphere feature in POV-Ray 3.0 are somewhat
  8595. experimental. There is a high probability that the design and implementation
  8596. of these features will be changed in future versions. We cannot guarantee
  8597. that scenes using these features in 3.0 will render identically in future
  8598. releases or that full backwards compatibility of language syntax can be
  8599. maintained.
  8600.  
  8601. The atmosphere feature can be used to model the interaction of light with
  8602. particles in the air. Beams of light will become visible and objects will
  8603. cast shadows into the fog or dust that's filling the air.
  8604.  
  8605. The atmosphere model used in POV-Ray assumes a constant particle density
  8606. everywhere except solid objects. If you want to create cloud like fogs or
  8607. smoke you'll have to use the halo texturing feature described in section
  8608. "Halos".
  8609.  
  8610. 4.10.4.1         Starting With an Empty Room
  8611.  
  8612. We want to create a simple scene to explain how the atmosphere feature works
  8613. and how you'll get good results.
  8614.  
  8615. Imagine a simple room with a window. Light falls through the window and is
  8616. scattered by the dust particles in the air. You'll see beams of light coming
  8617. from the window and shining on the floor.
  8618.  
  8619. We want to model this scene step by step. The following examples start with
  8620. the room, the window and a spotlight somewhere outside the room. Currently
  8621. there's no atmosphere to be able to verify if the lighting is correct
  8622. (atmos1.pov).
  8623.  
  8624.   camera {
  8625.     location <-10, 8, -19>
  8626.     look_at <0, 5, 0>
  8627.     angle 75
  8628.   }
  8629.  
  8630.   background { color rgb <0.2, 0.4, 0.8> }
  8631.  
  8632.   light_source { <0, 19, 0> color rgb 0.5 atmosphere off }
  8633.  
  8634.   light_source {
  8635.     <40, 25, 0> color rgb <1, 1, 1>
  8636.     spotlight
  8637.     point_at <0, 5, 0>
  8638.     radius 20
  8639.     falloff 20
  8640.     atmospheric_attenuation on
  8641.   }
  8642.  
  8643.   union {
  8644.     difference {
  8645.       box { <-21, -1, -21>, <21, 21, 21> }
  8646.       box { <-20, 0, -20>, <20, 20, 20> }
  8647.       box { <19.9, 5, -3>, <21.1, 15, 3> }
  8648.     }
  8649.     box { <20, 5, -0.25>, <21, 15, 0.25> }
  8650.     box { <20, 9.775, -3>, <21, 10.25, 3> }
  8651.     pigment { color red 1 green 1 blue 1 }
  8652.     finish { ambient 0.2 diffuse 0.5 }
  8653.   }
  8654.  
  8655.  
  8656. The empty room we want to start with.
  8657.  
  8658. The point light source is used to illuminate the room from inside without any
  8659. interaction with the atmosphere. This is done by adding atmosphere off . We
  8660. don't have to care about this light when we add the atmosphere later.
  8661.  
  8662. The spotlight is used with the atmospheric_attenuation keyword. This means
  8663. that light coming from the spotlight will be diminished by the atmosphere.
  8664.  
  8665. The union object is used to model the room and the window. Since we use the
  8666. difference between two boxes to model the room (the first two boxes in the
  8667. difference statement) there is no need for setting the union hollow. If we
  8668. are inside this room we actually will be outside the object (see also "Using
  8669. Hollow Objects and Atmosphere").
  8670.  
  8671. 4.10.4.2         Adding Dust to the Room
  8672.  
  8673. The next step is to add an atmosphere to the room. This is done by the
  8674. following few lines (atmos2.pov).
  8675.  
  8676.   atmosphere {
  8677.     type 1
  8678.     samples 10
  8679.     distance 40
  8680.     scattering 0.2
  8681.   }
  8682.  
  8683.  
  8684. The type keyword selects the type of atmospheric scattering we want to use.
  8685. In this case we use the isotropic scattering that equally scatters light in
  8686. all directions (see "Atmosphere" for more details about the different
  8687. scattering types).
  8688.  
  8689. The samples keyword determines the number of samples used in accumulating the
  8690. atmospheric effect. For every ray samples are taken along the ray to
  8691. determine whether a sample is lit by a light source or not. If the sample is
  8692. lit the amount of light scattered into the direction of the viewer is
  8693. determined and added to the total intensity.
  8694.  
  8695. You can always start with an arbitrary number of samples. If the results do
  8696. not fit your ideas you can increase the sampling rate to get better results.
  8697. The problem of choosing a good sampling rate is the trade-off between a
  8698. satisfying image and a fast rendering. A high sampling rate will almost
  8699. always work but the rendering will also take a very long time. That's
  8700. something to experiment with.
  8701.  
  8702. The distance keyword specifies the density of the atmosphere. It works in the
  8703. same way as the distance parameter of the fog feature.
  8704.  
  8705. Last but not least will the scattering value determine the amount of light
  8706. that is scattered by the particles (the remaining light is absorbed). As
  8707. you'll later see this parameter is very useful in adjusting the overall
  8708. brightness of the atmosphere.
  8709.  
  8710. After adding some dust beams of light become visible.
  8711.  
  8712. Looking at the image created from the above scene you'll notice some very
  8713. ugly anti-aliasing artifacts known as mach-bands. They are the result of a
  8714. low sampling rate.
  8715.  
  8716.  
  8717. 4.10.4.3         Choosing a Good Sampling Rate
  8718.  
  8719. As you've seen a too low sampling rate can cause some ugly results. There are
  8720. some ways of reducing or even avoiding those problems.
  8721.  
  8722. The brute force approach is to increase the sampling rate until the artifacts
  8723. vanish and you get a satisfying image. Though this will always work it is a
  8724. bad idea because it is very time consuming. A better approach is to use
  8725. jittering and anti-aliasing first. If both features don't help you'll have to
  8726. increase the sampling rate.
  8727.  
  8728. Jittering moves each sample point by a small, random amount along the
  8729. sampling direction. This helps to reduce regular features resulting from
  8730. aliasing. There is (hardly) nothing more annoying to the human visual system
  8731. than the regular features resulting from a low sampling rate. It's much
  8732. better to add some extra noise to the image by jittering the sample
  8733. positions. The human eye is much more forgiving to that.
  8734.  
  8735. Use the jitter keyword followed by the amount of jittering you want to use.
  8736. Good jittering values are up to 0.5, higher values result in too much noise.
  8737.  
  8738. You should be aware that jittering can not fix the artifacts introduced by a
  8739. too low sampling rate. It can only make them less visible.
  8740.  
  8741. An additional and better way of reducing aliasing artifacts is to use
  8742. (adaptive) super-sampling. This method casts additional samples where it is
  8743. likely that they are needed. If the intensity between two adjacent samples
  8744. differs too much additional samples are taken in-between. This step is done
  8745. recursively until a specified recursion level is reached or the sample get
  8746. close to each other.
  8747.  
  8748. The aa_level and aa_threshold keywords give full control over the
  8749. super-sampling process. The aa_level keyword determines the maximum recursion
  8750. level while aa_threshold specifies the maximum allowed difference between two
  8751. sample before the super-sampling is done.
  8752.  
  8753. After all this theory we get back to our sample scene and add the appropriate
  8754. keywords to use both jittering and super-sampling (atmos3.pov).
  8755.  
  8756.   atmosphere {
  8757.     type 1
  8758.     samples 50
  8759.     distance 40
  8760.     scattering 0.2
  8761.     aa_level 4
  8762.     aa_threshold 0.1
  8763.     jitter 0.2
  8764.   }
  8765.  
  8766.  
  8767. A very low threshold value was chosen to super-sample even between adjacent
  8768. points with a very similar intensity. The maximum recursion level of 4 will
  8769. lead to a maximum of fifteen super-samples.
  8770.  
  8771. If you are looking at the results that you get after adding jittering and
  8772. super-sampling you won't be satisfied. The only way of reducing the still
  8773. visible artifacts is to increase the sampling rate by choosing a higher
  8774. number of samples.
  8775.  
  8776. A high sampling rate leads to a satisfying image.
  8777.  
  8778. Doing this you'll get a good result showing (almost) no artifacts. BTW, the
  8779. amount of dust floating around in this room may be a little bit exaggerated
  8780. but it's just an example. And examples tend to be exaggerated.
  8781.  
  8782. 4.10.4.4         Using a Coloured Atmosphere
  8783.  
  8784. You can assign a color to the atmosphere that gives you more control over the
  8785. atmosphere's appearance. First of all the color is used to filter all light
  8786. passing through it, whether it comes from light sources, reflected and
  8787. refracted rays, or the background. The amount by which the passing light is
  8788. filtered by the atmosphere's color is determined by the color's filter value.
  8789. A value of 0 means that the light is not influenced by the atmosphere's color
  8790. while a value of 1 means that all light will be filtered by the color.
  8791.  
  8792. If you want to create a reddish atmosphere for example, you can add the
  8793. following line to the atmosphere statement used in the above example.
  8794.  
  8795.   color rgbf <1, 0, 0, 0.25>
  8796.  
  8797.  
  8798. Just using rgb <1,0,0> does not work because the color's filter value will be
  8799. zero and thus no light will be filtered by the color, i. e. no light will be
  8800. multiplied with the color's RGB components.
  8801.  
  8802. The filter value of 0.25 means that 25% of the light passing through the
  8803. atmosphere will be filtered by the red color and 75% will pass unfiltered.
  8804.  
  8805. The transmittance channel of the atmosphere's color is used to specify a
  8806. minimum translucency. By default the transmittance channel is zero and thus
  8807. there is no such minimum translucency. Using a positive value lets you
  8808. determine the amount of background light that will always pass through the
  8809. atmosphere, regardless of its thickness set by the distance keyword.
  8810.  
  8811. If you use e.g. a color of rgbt <0,0,0,0.3> with our room example you can
  8812. make the blue background become visible. Until now it was hidden by the
  8813. atmosphere.
  8814.  
  8815. 4.10.4.5         Atmosphere Tips
  8816.  
  8817. It is very difficult to get satisfying results when using the atmosphere
  8818. feature. Some of the more common problems will be discussed in the next
  8819. sections to help you to solve them (see also the FAQ section about the
  8820. atmosphere in "Atmosphere Questions").
  8821.  
  8822. 4.10.4.5.1       Choosing the Distance and Scattering Parameters
  8823.  
  8824. The first difficult step is to choose a good distance and scattering value.
  8825. You need to be able to control the visibility of the objects in the scene and
  8826. the atmospheric effects.
  8827.  
  8828. The best approach is to choose the distance value first. This value
  8829. determines the visibility of the objects in the scene regardless of
  8830. atmospheric light scattering. It works in the same way as the distance value
  8831. of the fog feature.
  8832.  
  8833. Since fog is very similar to the unlit atmosphere you can use a fog instead
  8834. of an atmosphere to quickly choose a working distance value. If you do this
  8835. with room scene we used earlier you would use the following fog statement
  8836. instead of the atmosphere (atmos4.pov).
  8837.  
  8838.   fog {
  8839.     distance 40
  8840.     color rgb <0, 0, 0>
  8841.   }
  8842.  
  8843.  
  8844. A black fog can be used to get a working distance value for the atmosphere.
  8845.  
  8846. The black color is used to simulate the attenuation you'll get in those parts
  8847. of the atmosphere scene lying in shadow.
  8848.  
  8849. If you want to use a colored atmosphere you'll have to use the same color for
  8850. the fog as you want to use for the atmosphere, including the filter and
  8851. transmittance channel values (see "Using a Coloured Atmosphere" and
  8852. "Atmosphere" for an explanation of the atmosphere's color).
  8853.  
  8854. If you (roughly) want to simulate the appearance of those parts lit by a
  8855. light source you can use the color of the atmosphere inside the fog statement
  8856. instead.
  8857.  
  8858. After you are satisfied with the distance value you'll have to choose a
  8859. scattering value. This value lets you fit the atmosphere's intensity to your
  8860. needs. Starting with a value of one you have to increase the value if the
  8861. atmosphere effects are hardly visible. If you don't see anything in the lit
  8862. parts of the atmosphere you'll have to decrease the value.
  8863.  
  8864. You should be aware that you may have to use very small or very large values
  8865. to get the desired results.
  8866.  
  8867. 4.10.4.5.2       Atmosphere and Light Sources
  8868.  
  8869. The best results are generated with spotlights and cylindrical light sources.
  8870. They create nice beams of light and are fast to render because the
  8871. atmospheric sampling takes only place inside the light cone of the spotlight
  8872. or light cylinder of the cylindrical light.
  8873.  
  8874. If you want to add a light source that does not interact with the atmosphere
  8875. you can use the atmosphere keyword inside the light source statement (see
  8876. "Atmosphere Interaction"). Just add atmosphere off.
  8877.  
  8878. By default the light coming from any light source will not be diminished by
  8879. the atmosphere. Thus the highlights in your scene will normally be too
  8880. bright. This can be changed with atmospheric_attenuation on.
  8881.  
  8882. 4.10.4.5.3       Atmosphere Scattering Types
  8883.  
  8884. The different scattering types listed in "Atmosphere" can be used to model
  8885. different types of particles. This is something for you to experiment with.
  8886.  
  8887. The Rayleigh scattering is used for small particles like dust and smoke while
  8888. the Mie scattering is used for fog.
  8889.  
  8890. If you ever saw the lighthouse scene in the movie Casper you'll know what
  8891. effect the scattering type has. In this scene the beam of light coming from
  8892. the lighthouse becomes visible while it points nearly towards the viewer. As
  8893. it starts to point away from the viewer it vanishes. This behaviour is
  8894. typical for minuscule water droplets as modeled by the Mie scattering.
  8895.  
  8896. 4.10.4.5.4       Increasing the Image Resolution
  8897.  
  8898. You have to be aware that you may have to increase the atmosphere sampling
  8899. rate if you increase the resolution of the image. Otherwise some aliasing
  8900. artifacts that were no visible at the lower resolution may become visible.
  8901.  
  8902. 4.10.4.5.5       Using Hollow Objects and Atmosphere
  8903.  
  8904. Whenever you use the atmosphere feature you have to make sure that all
  8905. objects that ought to be filled with atmosphere are set to hollow using the
  8906. hollow keyword.
  8907.  
  8908. Even though this is not obvious this holds for infinite and patch objects
  8909. like quadrics, quartics, triangles, polygons, etc. Whenever you add one of
  8910. those objects you should add the hollow keyword as long as you are not
  8911. absolutely sure you don't need it. You also have to make sure that all
  8912. objects the camera is inside are set to be hollow.
  8913.  
  8914. Whenever you get unexpected results you should check for solid objects and
  8915. set them to be hollow.
  8916.  
  8917. 4.10.5           The Rainbow
  8918.  
  8919. The rainbow feature can be used to create rainbows and maybe other more
  8920. strange effects. The rainbow is a fog like effect that is restricted to a
  8921. cone-like volume.
  8922.  
  8923. 4.10.5.1         Starting With a Simple Rainbow
  8924.  
  8925. The rainbow is specified with a lot of parameters: the angle under which it
  8926. is visible, the width of the color band, the direction of the incoming light,
  8927. the fog-like distance based particle density and last not least the color map
  8928. to be used.
  8929.  
  8930. The size and shape of the rainbow are determined by the angle and width
  8931. keywords. The direction keyword is used to set the direction of the incoming
  8932. light, thus setting the rainbow's position. The rainbow is visible when the
  8933. angle between the direction vector and the incident light direction is larger
  8934. than angle-width/2 and smaller than angle+width/2.
  8935.  
  8936. The incoming light is the virtual light source that is responsible for the
  8937. rainbow. There needn't be a real light source to create the rainbow effect.
  8938.  
  8939. The rainbow is a fog-like effect, i.e. the rainbow's color is mixed with the
  8940. background color based on the distance to the intersection point. If you
  8941. choose small distance values the rainbow will be visible on objects, not just
  8942. in the background. You can avoid this by using a very large distance value.
  8943.  
  8944. The color map is the crucial part of the rainbow since it contains all the
  8945. colors that normally can be seen in a rainbow. The color of the innermost
  8946. color band is taken from the color map entry 0 while the outermost band is
  8947. take from entry 1. You should note that due to the limited color range any
  8948. monitor can display it is impossible to create a real rainbow. There are just
  8949. some colors that you cannot display.
  8950.  
  8951. The filter channel of the rainbow's color map is used in the same way as with
  8952. fogs. It determines how much of the light passing through the rainbow is
  8953. filtered by the color.
  8954.  
  8955. The following example shows a simple scene with a ground plane, three spheres
  8956. and a somewhat exaggerated rainbow (rainbow1.pov).
  8957.  
  8958.   #include "colors.inc"
  8959.  
  8960.   camera {
  8961.     location <0, 20, -100>
  8962.     look_at <0, 25, 0>
  8963.     angle 80
  8964.   }
  8965.  
  8966.   background { color SkyBlue }
  8967.  
  8968.   plane { y, -10 pigment { colour Green } }
  8969.  
  8970.   light_source {<100, 120, 40> colour White}
  8971.  
  8972.   // declare rainbow's colours
  8973.  
  8974.   #declare r_violet1 = colour rgbf<1.0, 0.5, 1.0, 1.0>
  8975.   #declare r_violet2 = colour rgbf<1.0, 0.5, 1.0, 0.8>
  8976.   #declare r_indigo  = colour rgbf<0.5, 0.5, 1.0, 0.8>
  8977.   #declare r_blue    = colour rgbf<0.2, 0.2, 1.0, 0.8>
  8978.   #declare r_cyan    = colour rgbf<0.2, 1.0, 1.0, 0.8>
  8979.   #declare r_green   = colour rgbf<0.2, 1.0, 0.2, 0.8>
  8980.   #declare r_yellow  = colour rgbf<1.0, 1.0, 0.2, 0.8>
  8981.   #declare r_orange  = colour rgbf<1.0, 0.5, 0.2, 0.8>
  8982.   #declare r_red1    = colour rgbf<1.0, 0.2, 0.2, 0.8>
  8983.   #declare r_red2    = colour rgbf<1.0, 0.2, 0.2, 1.0>
  8984.  
  8985.   // create the rainbow
  8986.  
  8987.   rainbow {
  8988.     angle 42.5
  8989.     width 5
  8990.     distance 1.0e7
  8991.     direction <-0.2, -0.2, 1>
  8992.     jitter 0.01
  8993.     colour_map {
  8994.       [0.000  colour r_violet1]
  8995.       [0.100  colour r_violet2]
  8996.       [0.214  colour r_indigo]
  8997.       [0.328  colour r_blue]
  8998.       [0.442  colour r_cyan]
  8999.       [0.556  colour r_green]
  9000.       [0.670  colour r_yellow]
  9001.       [0.784  colour r_orange]
  9002.       [0.900  colour r_red1]
  9003.     }
  9004.   }
  9005.  
  9006.  
  9007. Some irregularity is added to the color bands using the jitter keyword.
  9008.  
  9009. A colorful rainbow.
  9010.  
  9011. The rainbow in our sample is much too bright. You'll never see a rainbow like
  9012. this in reality. You can decrease the rainbow's colors by decreasing the RGB
  9013. values in the color map.
  9014.  
  9015. 4.10.5.2         Increasing the Rainbow's Translucency
  9016.  
  9017. The result we have so far looks much too bright. Just reducing the rainbow's
  9018. color helps but it's much better to increase the translucency of the rainbow
  9019. because it is more realistic if the background is visible through the
  9020. rainbow.
  9021.  
  9022. We can use the transmittance channel of the colors in the color map to
  9023. specify a minimum translucency, just like we did with the fog. To get
  9024. realistic results we have to use very large transmittance values as you can
  9025. see in the following example (rainbow2.pov).
  9026.  
  9027.   rainbow {
  9028.     angle 42.5
  9029.     width 5
  9030.     distance 1.0e7
  9031.     direction <-0.2, -0.2, 1>
  9032.     jitter 0.01
  9033.     colour_map {
  9034.       [0.000  colour r_violet1 transmit 0.98]
  9035.       [0.100  colour r_violet2 transmit 0.96]
  9036.       [0.214  colour r_indigo  transmit 0.94]
  9037.       [0.328  colour r_blue    transmit 0.92]
  9038.       [0.442  colour r_cyan    transmit 0.90]
  9039.       [0.556  colour r_green   transmit 0.92]
  9040.       [0.670  colour r_yellow  transmit 0.94]
  9041.       [0.784  colour r_orange  transmit 0.96]
  9042.       [0.900  colour r_red1    transmit 0.98]
  9043.     }
  9044.   }
  9045.  
  9046.  
  9047. The transmittance values increase at the outer bands of the rainbow to make
  9048. it softly blend into the background.
  9049.  
  9050. A much more realistic rainbow.
  9051.  
  9052.  
  9053. 4.10.5.3         Using a Rainbow Arc
  9054.  
  9055. Currently our rainbow has a circular shape, even though most of it is hidden
  9056. below the ground plane. You can easily create a rainbow arc by using the
  9057. arc_angle keyword with an angle below 360 degrees.
  9058.  
  9059. If you use arc_angle 120 for example you'll get a rainbow arc that abruptly
  9060. vanishes at the arc's ends. This does not look good. To avoid this the
  9061. falloff_angle keyword can be used to specify a region where the arc smoothly
  9062. blends into the background.
  9063.  
  9064. As explained in the rainbow's reference section (see "Rainbow") the arc
  9065. extends from -arc_angle/2 to arc_angle/2 while the blending takes place from
  9066. -arc_angle/2 to -falloff_angle/2 and falloff_angle/2 to arc_angle/2. This is
  9067. the reason why the falloff_angle has to be smaller or equal to the arc_angle.
  9068.  
  9069.  
  9070. In the following examples we use an 120 degrees arc with a 45 degree falloff
  9071. region on both sides of the arc (rainbow3.pov).
  9072.  
  9073.   rainbow {
  9074.     angle 42.5
  9075.     width 5
  9076.     arc_angle 120
  9077.     falloff_angle 30
  9078.     distance 1.0e7
  9079.     direction <-0.2, -0.2, 1>
  9080.     jitter 0.01
  9081.     colour_map {
  9082.       [0.000  colour r_violet1 transmit 0.98]
  9083.       [0.100  colour r_violet2 transmit 0.96]
  9084.       [0.214  colour r_indigo  transmit 0.94]
  9085.       [0.328  colour r_blue    transmit 0.92]
  9086.       [0.442  colour r_cyan    transmit 0.90]
  9087.       [0.556  colour r_green   transmit 0.92]
  9088.       [0.670  colour r_yellow  transmit 0.94]
  9089.       [0.784  colour r_orange  transmit 0.96]
  9090.       [0.900  colour r_red1    transmit 0.98]
  9091.     }
  9092.   }
  9093.  
  9094.  
  9095. The arc angles are measured against the rainbows up direction which can be
  9096. specified using the up keyword. By default the up direction is the y-axis.
  9097.  
  9098. A rainbow arc.
  9099.  
  9100.  
  9101. 4.10.6           Animation
  9102.  
  9103. There are a number of programs available that will take a series of still TGA
  9104. files (such as POV-Ray outputs) and assemble them into animations. Such
  9105. programs can produce AVI, MPEG, FLI/FLC, or even animated GIF files (for use
  9106. on the World Wide Web). The trick, therefore, is how to produce the frames.
  9107. That, of course, is where POV-Ray comes in. In earlier versions producing an
  9108. animation series was no joy, as everything had to be done manually. We had to
  9109. set the clock variable, and handle producing unique file names for each
  9110. individual frame by hand. We could achieve some degree of automation by using
  9111. batch files or similar scripting devices, but still, We had to set it all up
  9112. by hand, and that was a lot of work (not to mention frustration... imagine
  9113. forgetting to set the individual file names and coming back 24 hours later to
  9114. find each frame had overwritten the last).
  9115.  
  9116. Now, at last, with POV-Ray 3, there is a better way. We no longer need a
  9117. separate batch script or external sequencing programs, because a few simple
  9118. settings in our INI file (or on the command line) will activate an internal
  9119. animation sequence which will cause POV-Ray to automatically handle the
  9120. animation loop details for us.
  9121.  
  9122. Actually, there are two halves to animation support: those settings we put in
  9123. the INI file (or on the command line), and those code modifications we work
  9124. into our scene description file. If we've already worked with animation in
  9125. previous versions of POV-Ray, we can probably skip ahead to the section "INI
  9126. File Settings" below. Otherwise, let's start with basics. Before we get to
  9127. how to activate the internal animation loop, let's look at a couple examples
  9128. of how a couple of keywords can set up our code to describe the motions of
  9129. objects over time.
  9130.  
  9131. 4.10.6.1         The Clock Variable: Key To It All
  9132.  
  9133. POV-Ray supports an automatically declared floating point variable identified
  9134. as clock (all lower case). This is the key to making image files that can be
  9135. automated. In command line operations, the clock variable is set using the +k
  9136. switch. For example, \Clo{+k3.4} from the command line would set the value of
  9137. clock to 3.4. The same could be accomplished from the INI file
  9138. using\IFKINDEX{Clock}
  9139.  
  9140.   Clock = 3.4
  9141.  
  9142.  
  9143. If we don't set clock for anything, and the animation loop is not used (as
  9144. will be described a little later) the clock variable is still there - it's
  9145. just set for the default value of 0.0, so it is possible to set up some POV
  9146. code for the purpose of animation, and still render it as a still picture
  9147. during the object/world creation stage of our project.
  9148.  
  9149. The simplest example of using this to our advantage would be having an object
  9150. which is travelling at a constant rate, say, along the x-axis. We would have
  9151. the statement
  9152.  
  9153.   translate <clock, 0, 0>
  9154.  
  9155.  
  9156. in our object's declaration, and then have the animation loop assign
  9157. progressively higher values to clock. And that's fine, as long as only one
  9158. element or aspect of our scene is changing, but what happens when we want to
  9159. control multiple changes in the same scene simulatneously?
  9160.  
  9161. The secret here is to use normalized clock values, and then make other
  9162. variables in your scene proportional to clock. That is, when we set up our
  9163. clock, (we're getting to that, patience!) have it run from 0.0 to 1.0, and
  9164. then use that as a multiplier to some other values. That way, the other
  9165. values can be whatever we need them to be, and clock can be the same 0 to 1
  9166. value for every application. Let's look at a (relatively) simple example
  9167.  
  9168.   #include "colors.inc"
  9169.  
  9170.   camera {
  9171.     location <0, 3, -6>
  9172.     look_at <0, 0, 0>
  9173.   }
  9174.  
  9175.   light_source { <20, 20, -20> color White }
  9176.  
  9177.   plane { y, 0
  9178.     pigment { checker color White color Black }
  9179.   }
  9180.  
  9181.   sphere { <0, 0, 0> , 1
  9182.     pigment {
  9183.       gradient x
  9184.       color_map {
  9185.         [0.0 Blue  ]
  9186.         [0.5 Blue  ]
  9187.         [0.5 White ]
  9188.         [1.0 White ]
  9189.       }
  9190.       scale .25
  9191.     }
  9192.     rotate <0, 0, -clock*360>
  9193.     translate <-pi, 1, 0>
  9194.     translate <2*pi*clock, 0, 0>
  9195.   }
  9196.  
  9197.  
  9198. Assuming that a series of frames is run with the clock progressively going
  9199. from 0.0 to 1.0, the above code will produce a striped ball which rolls from
  9200. left to right across the screen. We have two goals here:
  9201.  
  9202.   2.Rotate the ball in exactly the right proportion to its linear movement to
  9203.     imply that it is rolling -- not gliding -- to its final position.
  9204.  
  9205.  
  9206. Taking the second goal first, we start with the sphere at the origin, because
  9207. anywhere else and rotation will cause it to orbit the origin instead of
  9208. rotating. Throughout the course of the animation, the ball will turn one
  9209. complete 360 degree turn. Therefore, we used the formula, 360*clock to
  9210. determine the rotation in each frame. Since clock runs 0 to 1, the rotation
  9211. of the sphere runs from 0 degrees through 360.
  9212.  
  9213. Then we used the first translation to put the sphere at its initial starting
  9214. point. Remember, we couldn't have just declared it there, or it would have
  9215. orbited the origin, so before we can meet our other goal (translation), we
  9216. have to compensate by putting the sphere back where it would have been at the
  9217. start. After that, we re-translate the sphere by a clock relative distance,
  9218. causing it to move relative to the starting point. We've chosen the formula
  9219. of 2*pi* r*clock (the widest circumference of the sphere times current clock
  9220. value) so that it will appear to move a distance equal to the circumference
  9221. of the sphere in the same time that it rotates a complete 360 degrees. In
  9222. this way, we've synchronized the rotation of the sphere to its translation,
  9223. making it appear to be smoothly rolling along the plane.
  9224.  
  9225. Besides allowing us to coordinate multiple aspects of change over time more
  9226. cleanly, mathematically speaking, the other good reason for using normalized
  9227. clock values is that it will not matter whether we are doing a ten frame
  9228. animated GIF, or a three hundred frame AVI. Values of the clock are
  9229. proportioned to the number of frames, so that same POV code will work without
  9230. regard to how long the frame sequence is. Our rolling ball will still travel
  9231. the exact same amount no matter how many frames our animation ends up with.
  9232.  
  9233. 4.10.6.2         Clock Dependant Variables And Multi-Stage Animations
  9234.  
  9235. Okay, what if we wanted the ball to roll left to right for the first half of
  9236. the animation, then change direction 135 degrees and roll right to left, and
  9237. toward the back of the scene. We would need to make use of POV's new
  9238. conditional rendering directives, and test the clock value to determine when
  9239. we reach the halfway point, then start rendering a different clock dependant
  9240. sequence. But our goal, as above, it to be working in each stage with a
  9241. variable in the range of 0 to 1 (normalized) because this makes the math so
  9242. much cleaner to work with when we have to control multiple aspects during
  9243. animation. So let's assume we keep the same camera, light, and plane, and let
  9244. the clock run from 0 to 2! Now, replace the single sphere declaration with
  9245. the following...
  9246.  
  9247.   #if ( clock <= 1 )
  9248.     sphere { <0, 0, 0> , 1
  9249.       pigment {
  9250.         gradient x
  9251.         color_map {
  9252.           [0.0 Blue  ]
  9253.           [0.5 Blue  ]
  9254.           [0.5 White ]
  9255.           [1.0 White ]
  9256.         }
  9257.         scale .25
  9258.       }
  9259.       rotate <0, 0, -clock*360>
  9260.       translate <-pi, 1, 0>
  9261.       translate <2*pi*clock, 0, 0>
  9262.     }
  9263.   #else
  9264.     // (if clock is > 1, we're on the second phase)
  9265.  
  9266.     // we still want to work with  a value from 0 - 1
  9267.  
  9268.     #declare ElseClock = clock - 1
  9269.  
  9270.     sphere { <0, 0, 0> , 1
  9271.       pigment {
  9272.         gradient x
  9273.         color_map {
  9274.           [0.0 Blue  ]
  9275.           [0.5 Blue  ]
  9276.           [0.5 White ]
  9277.           [1.0 White ]
  9278.         }
  9279.         scale .25
  9280.       }
  9281.       rotate <0, 0, ElseClock*360>
  9282.       translate <-2*pi*ElseClock, 0, 0>
  9283.       rotate <0, 45, 0>
  9284.       translate <pi, 1, 0>
  9285.     }
  9286.   #end
  9287.  
  9288.  
  9289. If we spotted the fact that this will cause the ball to do an unrealistic
  9290. snap turn when changing direction, bonus points for us - we're a born
  9291. animator. However, for the simplicity of the example, let's ignore that for
  9292. now. It will be easy enough to fix in the real world, once we examine how the
  9293. existing code works.
  9294.  
  9295. All we did differently was assume that the clock would run 0 to 2, and that
  9296. we wanted to be working with a normalized value instead. So when the clock
  9297. goes over 1.0, POV assumes the second phase of the journey has begun, and we
  9298. declare a new variable Elseclock which we make relative to the original built
  9299. in clock, in such a way that while clock is going 1 to 2, Elseclock is going
  9300. 0 to 1. So, even though there is only one clock, there can be as many
  9301. additional variables as we care to declare (and have memory for), so even in
  9302. fairly complex scenes, the single clock variable can be made the common
  9303. coordinating factor which orchestrates all other motions.
  9304.  
  9305. 4.10.6.3         The Phase Keyword
  9306.  
  9307. There is another keyword we should know for purposes of animations: the phase
  9308. keyword. The phase keyword can be used on many texture elements, especially
  9309. those that can take a color, pigment, normal or texture map. Remember the
  9310. form that these maps take. For example:
  9311.  
  9312.   color_map {
  9313.     [0.00 White ]
  9314.     [0.25 Blue ]
  9315.     [0.76 Green ]
  9316.     [1.00 Red ]
  9317.   }
  9318.  
  9319.  
  9320. The floating point value to the left inside each set of brackets helps
  9321. POV-Ray to map the color values to various areas of the object being
  9322. textured. Notice that the map runs cleanly from 0.0 to 1.0?
  9323.  
  9324. Phase causes the color values to become shifted along the map by a floating
  9325. point value which follows the keyword phase. Now, if we are using a
  9326. normalized clock value already anyhow, we can make the variable clock the
  9327. floating point value associated with phase, and the pattern will smoothly
  9328. shift over the course of the animation. Let's look at a common example using
  9329. a gradient normal pattern
  9330.  
  9331.   #include "colors.inc"
  9332.   #include "textures.inc"
  9333.  
  9334.   #background { rgb<0.8, 0.8, 0.8> }
  9335.  
  9336.   camera {
  9337.     location <1.5, 1, -30>
  9338.     look_at <0, 1, 0>
  9339.     angle 10
  9340.   }
  9341.  
  9342.   light_source { <-100, 20, -100> color White }
  9343.  
  9344.   // flag
  9345.  
  9346.   polygon { 5, <0, 0>, <0, 1>, <1, 1>, <1, 0>, <0, 0>
  9347.     pigment { Blue }
  9348.     normal {
  9349.       gradient x
  9350.       phase clock
  9351.       scale <0.2, 1, 1>
  9352.       sine_wave
  9353.     }
  9354.     scale <3, 2, 1>
  9355.     translate <-1.5, 0, 0>
  9356.   }
  9357.  
  9358.   // flagpole
  9359.  
  9360.   cylinder { <-1.5, -4, 0>, <-1.5, 2.25, 0>, 0.05
  9361.     texture { Silver_Metal }
  9362.   }
  9363.  
  9364.   // polecap
  9365.  
  9366.   sphere { <-1.5, 2.25, 0>, 0.1
  9367.     texture { Silver_Metal }
  9368.   }
  9369.  
  9370.  
  9371. Now, here we've created a simple blue flag with a gradient normal pattern on
  9372. it. We've forced the gradient to use a sine-wave type wave so that it looks
  9373. like the flag is rolling back and forth as though flapping in a breeze. But
  9374. the real magic here is that phase keyword. It's been set to take the clock
  9375. variable as a floating point value which, as the clock increments slowly
  9376. toward 1.0, will cause the crests and troughs of the flag's wave to shift
  9377. along the x-axis. Effectively, when we animate the frames created by this
  9378. code, it will look like the flag is actually rippling in the wind.
  9379.  
  9380. This is only one, simple example of how a clock dependant phase shift can
  9381. create interesting animation effects. Trying phase will all sorts of texture
  9382. patterns, and it is amazing the range of animation effects we can create
  9383. simply by phase alone, without ever actually moving the object.
  9384.  
  9385. 4.10.6.4         Do Not Use Jitter Or Crand
  9386.  
  9387. One last piece of basic information to save frustration. Because jitter is an
  9388. element of anti-aliasing, we could just as easily have mentioned this under
  9389. the INI file settings section, but there are also forms of anti-aliasing used
  9390. in area lights, and the new atmospheric effects of POV-Ray, so now is as good
  9391. a time as any.
  9392.  
  9393. Jitter is a very small amount of random ray perturbation designed to diffuse
  9394. tiny aliasing errors that might not otherwise totally disappear, even with
  9395. intense anti-aliasing. By randomizing the placement of erroneous pixels, the
  9396. error becomes less noticable to the human eye, because the eye and mind are
  9397. naturally inclined to look for regular patterns rather than random
  9398. distortions.
  9399.  
  9400. This concept, which works fantasticly for still pictures, can become a
  9401. nightmare in animations. Because it is random in nature, it will be different
  9402. for each frame we render, and this becomes even more severe if we dither the
  9403. final results down to, say 256 color animations (such as FLC's). The result
  9404. is jumping pixels all over the scene, but especially concentrated any place
  9405. where aliasing would normally be a problem (e.g., where an infinite plane
  9406. disappears into the distance).
  9407.  
  9408. For this reason, we should always set jitter to off in area lights and
  9409. anti-aliasing options when preparing a scene for an animation. The
  9410. (relatively) small extra measure quality due to the use of jitter will be
  9411. offset by the ocean of jumpies that results. This general rule also applies
  9412. to any truly random texture elements, such as crand.
  9413.  
  9414. 4.10.6.5         INI File Settings
  9415.  
  9416. Okay, so we have a grasp of how to code our file for animation. We know about
  9417. the clock variable, user declared clock-relative variables, and the phase
  9418. keyword. We know not to jitter or crand when we render a scene, and we're all
  9419. set build some animations. Alright, let's have at it.
  9420.  
  9421. The first concept we'll need to know is the INI file settings, Initial_Frame
  9422. and Final_Frame. These are very handy settings that will allow us to render a
  9423. particular number of frames and each with its own unique frame number, in a
  9424. completely hands free way. It is of course, so blindingly simple that it
  9425. barely needs explanation, but here's an example anyway. We just add the
  9426. following lines to our favorite INI file settings
  9427.  
  9428.   Initial_Frame = 1
  9429.   Final_Frame = 20
  9430.  
  9431.  
  9432. and we'll initiate an automated loop that will generate 20 unique frames. The
  9433. settings themselves will automatically append a frame number onto the end of
  9434. whatever we have set the output file name for, thus giving each frame an
  9435. unique file number without having to think about it. Secondly, by default, it
  9436. will cycle the clock variable up from 0 to 1 in increments proportional to
  9437. the number of frames. This is very convenient, since, no matter whether we
  9438. are making a five frame animated GIF or a 300 frame MPEG sequence, we will
  9439. have a clock value which smoothly cylces from exactly the same start to
  9440. exactly the same finish.
  9441.  
  9442. Next, about that clock. In our example with the rolling ball code, we saw
  9443. that sometimes we want the clock to cycle through values other than the
  9444. default of 0.0 to 1.0. Well, when that's the case, there are setting for that
  9445. too. The format is also quite simple. To make the clock run, as in our
  9446. example, from 0.0 to 2.0, we would just add to your INI file the lines
  9447.  
  9448.   Initial_Clock = 0.0
  9449.   Final_Clock = 2.0
  9450.  
  9451.  
  9452. Now, suppose we were developing a sequence of 100 frames, and we detected a
  9453. visual glitch somewhere in frames, say 51 to 75. We go back over our code and
  9454. we think we've fixed it. We'd like to render just those 25 frames instead of
  9455. redoing the whole sequence from the beginning. What do we change?
  9456.  
  9457. If we said make Initial_Frame = 51, and Final_Frame = 75, we're wrong. Even
  9458. though this would re-render files named with numbers 51 through 75, they will
  9459. not properly fit into our sequence, because the clock will begin at its
  9460. initial value starting with frame 51, and cycle to final value ending with
  9461. frame 75. The only time Initial_Frame and Final_Frame should change is if we
  9462. are doing an essentially new sequence that will be appended onto existing
  9463. material.
  9464.  
  9465. If we wanted to look at just 51 through 75 of the original animation, we need
  9466. two new INI settings
  9467.  
  9468.   Subset_Start_Frame = 51
  9469.   Subset_End_Frame = 75
  9470.  
  9471.  
  9472. Added to settings from before, the clock will still cycle through its values
  9473. proportioned from frames 1 to 100, but we will only be rendering that part of
  9474. the sequence from the 51st to the 75th frames.
  9475.  
  9476. This should give us a basic idea of how to use animation. Although, this
  9477. introductory tutorial doesn't cover all the angles. For example, the last two
  9478. settings we just saw, subset animation, can take fractional values, like 0.5
  9479. to 0.75, so that the number of actual frames will not change what portion of
  9480. the animation is being rendered. There is also support for efficient odd-even
  9481. field rendering as would be useful for animations prepared for display in
  9482. interlaced playback such as television (see the reference section for full
  9483. details).
  9484.  
  9485. With POV-Ray 3 now fully supporting a complete host of animation options, a
  9486. whole fourth dimension is added to the raytracing experience. Whether we are
  9487. making a FLIC, AVI, MPEG, or simply an animated GIF for our web site,
  9488. animation support takes a lot of the tedium out of the process. And don't
  9489. forget that phase and clock can be used to explore the range of numerous
  9490. texture elements, as well as some of the more difficult to master objects
  9491. (hint: the julia fractal for example). So even if we are completely content
  9492. with making still scenes, adding animation to our repetoire can greatly
  9493. enhance our understanding of what POV-Ray is capable of. Adventure awaits!
  9494.  
  9495. 5                POV-Ray Reference
  9496.  
  9497. The reference section describes all command line switches and INI file
  9498. keywords that are used to set the options of POV-Ray, the scene description
  9499. language and all other features that are part of POV-Ray. It is supposed to
  9500. be used as a reference for looking up things. It does not contain detailed
  9501. explanations on how scenes are written or how POV-Ray is used. It just
  9502. explains all features, their syntax, applications, limits, drawbacks, etc.
  9503.  
  9504. 6                POV-Ray Options
  9505.  
  9506. POV-Ray was originally created as a command-line program for operating
  9507. systems without graphical interfaces, dialog boxes and pull-down menus. Most
  9508. versions of POV-Ray still use command-line switches to tell it what to do.
  9509. This documentation assumes you are using the command-line version. If you are
  9510. using Macintosh, MS-Windows or other GUI versions, there will be dialog boxes
  9511. or menus which do the same thing. There is system-specific documentation for
  9512. each system describing the specific commands.
  9513.  
  9514. 6.1              Setting POV-Ray Options
  9515.  
  9516. There are two distinct ways of setting POV-Ray options: command line switches
  9517. and INI file keywords. Both are explained in detail in the following
  9518. sections.
  9519.  
  9520. 6.1.1            Command Line Switches
  9521.  
  9522. Command line switches consist of a + (plus) or - (minus) sign, followed by
  9523. one or more alphabetic characters and possibly a numeric value. Here is a
  9524. typical command line with switches.
  9525.  
  9526.   POVRAY +Isimple.pov +V +W80 +H60
  9527.  
  9528.  
  9529. povray is the name of the program and it is followed by several switches.
  9530. Each switch begins with a plus or minus sign. The +I switch with the filename
  9531. tells POV-Ray what scene file it should use as input and +V tells the program
  9532. to output its status to the text screen as it's working. The +W and +H
  9533. switches set the width and height of the image in pixels. This image will be
  9534. 80 pixels wide by 60 pixels high.
  9535.  
  9536. In switches which toggle a feature, the plus turns it on and minus turns it
  9537. off. For example +P turns on the pause for keypress  when finished option
  9538. while -P turns it off. Other switches are used to specify values and do not
  9539. toggle a feature. Either plus or minus may be used in that instance. For
  9540. example +W320 sets the width to 320 pixels. You could also use -W320 and get
  9541. the same results.
  9542.  
  9543. Switches may be specified in upper or lower case. They are read left to right
  9544. but in general may be specified in any order. If you specify a switch more
  9545. than once, the previous value is generally overwritten with the last
  9546. specification. The only exception is the +L switch for setting library paths.
  9547. Up to ten unique paths may be specified.
  9548.  
  9549. Almost all +/- switches have an equivalent option which can be used in an INI
  9550. file which is described in the next section. A detailed description of each
  9551. switch is given in the option reference section.
  9552.  
  9553. 6.1.2            Using INI Files
  9554.  
  9555. Because it is difficult to set more than a few options on a command line, you
  9556. have the ability to put multiple options in one or more text files. These
  9557. initialization files or INI files have .ini as their default extension.
  9558. Previous versions of POV-Ray called them default files or DEF files. You may
  9559. still use existing DEF files with this version of POV-Ray.
  9560.  
  9561. The majority of options you use will be stored in INI files. The command line
  9562. switches are recommended for options which you will turn off or on frequently
  9563. as you perform test renderings of a scene you are developing. The file
  9564. povray.ini is automatically read if present. You may specify additional INI
  9565. files on the command-line by simply typing the file name on the command line.
  9566. For example:
  9567.  
  9568.   POVRAY MYOPTS.INI
  9569.  
  9570.  
  9571. If no extension is given, then .ini is assumed. POV-Ray knows this is not a
  9572. switch because it is not preceded by a plus or minus. In fact a common error
  9573. among new users is that they forget to put the +I switch before the input
  9574. file name. Without the switch, POV-Ray thinks that the scene file simple.pov
  9575. is an INI file. Don't forget! If no plus or minus precedes a command line
  9576. switch, it is assumed to be an INI file name.
  9577.  
  9578. You may have multiple INI files on the command line along with switches. For
  9579. example:
  9580.  
  9581.   POVRAY MYOPTS +V OTHER
  9582.  
  9583.  
  9584. This reads options from myopts.ini, then sets the +V switch, then reads
  9585. options from other.ini.
  9586.  
  9587. An INI file is a plain ASCII text file with options of the form...
  9588.  
  9589.   Option_keyword=VALUE ; Text after semicolon is a comment
  9590.  
  9591.  
  9592. For example the INI equivalent of the switch +Isimple.pov is...
  9593.  
  9594.   Input_File_Name=simple.pov
  9595.  
  9596.  
  9597. Options are read top to bottom in the file but in general may be specified in
  9598. any order. If you specify an option more than once, the previous values are
  9599. generally overwritten with the last specification. The only exception is the
  9600. Library_Path=path options. Up to ten unique paths may be specified.
  9601.  
  9602. Almost all INI-style options have equivalent +/- switches. The option
  9603. reference section gives a detailed description of all POV-Ray options. It
  9604. includes both the INI-style settings and the +/- switches.
  9605.  
  9606. The INI keywords are not case sensitive. Only one INI option is permitted per
  9607. line of text. You may also include switches in your INI file if they are
  9608. easier for you. You may have multiple switches per line but you should not
  9609. mix switches and INI options on the same line. You may nest INI files by
  9610. simply putting the file name on a line by itself with no equals sign after
  9611. it. Nesting may occur up to ten levels deep.
  9612.  
  9613. For example:
  9614.  
  9615.   ; This is a sample INI file. This entire line is a comment.
  9616.   ; Blank lines are permitted.
  9617.  
  9618.   Input_File_Name=simple.pov ;This sets the input file name
  9619.  
  9620.   +W80 +H60 ; Traditional +/- switches are permitted too
  9621.  
  9622.   MOREOPT   ; Read MOREOPT.INI and continue with next line
  9623.  
  9624.   +V        ; Another switch
  9625.  
  9626.   ; That's all folks!
  9627.  
  9628.  
  9629. INI files may have labeled sections so that more than one set of options may
  9630. be stored in a single file. Each section begins with a label in [] brackets.
  9631. For example:
  9632.  
  9633.   ; RES.INI
  9634.   ; This sample INI file is used to set resolution.
  9635.  
  9636.   +W120 +H100  ; This section has no label.
  9637.                ; Select it with "RES"
  9638.  
  9639.   [Low]
  9640.   +W80 +H60    ; This section has a label.
  9641.                ; Select it with "RES[Low]"
  9642.  
  9643.   [Med]
  9644.   +W320 +H200  ; This section has a label.
  9645.                ; Select it with "RES[Med]"
  9646.  
  9647.   [High]
  9648.   +W640 +H480  ; Labels are not case sensitive.
  9649.                ; "RES[high]" works
  9650.  
  9651.   [Really High]
  9652.   +W800 +H600  ; Labels may contain blanks
  9653.  
  9654.  
  9655. When you specify the INI file you should follow it with the section label in
  9656. brackets. For example...
  9657.  
  9658.   POVRAY RES[Med] +Imyfile.pov
  9659.  
  9660.  
  9661. POV-Ray reads res.ini and skips all options until it finds the label Med. It
  9662. processes options after that label until it finds another label and then it
  9663. skips. If no label is specified on the command line then only the unlabeled
  9664. area at the top of the file is read. If a label is specified, the unlabeled
  9665. area is ignored.
  9666.  
  9667. 6.1.3            Using the POVINI Environment Variable
  9668.  
  9669. The environment variable POVINI is used to specify the location and name of a
  9670. default INI file that is read every time POV-Ray is executed. If POVINI is
  9671. not specified a default INI file may be read depending on the platform used.
  9672. If the specified file does not exist a warning message is printed.
  9673.  
  9674. To set the environment variable under MS-DOS you might put the following line
  9675. in your autoexec.bat file...
  9676.  
  9677.   set POVINI=c:\povray3\default.ini
  9678.  
  9679.  
  9680. On most operating systems the sequence of reading options is as follows:
  9681.  
  9682.   1.Read options from default INI file specified by the POVINI environment
  9683.   2.Read switches from command line (this includes reading any specified
  9684.     INI/DEF files).
  9685.  
  9686.  
  9687. The POVRAYOPT environment variable supported by previous POV-Ray versions is
  9688. no longer available.
  9689.  
  9690. 6.2              Options Reference
  9691.  
  9692. As explained in the previous section, options may be specified by switches or
  9693. INI-style options. Almost all INI-style options have equivalent +/- switches
  9694. and most switches have equivalent INI-style option. The following sections
  9695. give a detailed description of each POV-Ray option. It includes both the
  9696. INI-style settings and the +/- switches.
  9697.  
  9698. The notation and terminology used is described in the tables below.
  9699.  
  9700.   Keyword=bool turn Keyword on if bool equals true, yes, on or 1 and turn it
  9701.   Keyword=fileeany valid file name. Note: some options prohibit the use of
  9702.                any of the above true or false values as a file name. They are
  9703.                noted in later sections.
  9704.  
  9705.  
  9706.   path yany directory name, drive optional, no final path separator ("\" or
  9707.         "/", depending on the operating system)
  9708.  
  9709.  
  9710. Unless otherwise specifically noted, you may assume that either a plus or
  9711. minus sign before a switch will produce the same results.
  9712.  
  9713. 6.2.1            Animation Options
  9714.  
  9715. POV-Ray 3.0 greatly improved its animation capability with the addition of an
  9716. internal animation loop, automatic output file name numbering and the ability
  9717. to shell out to the operating system to external utilities which can assemble
  9718. individual frames into an animation. The internal animation loop is simple
  9719. yet flexible. You may still use external programs or batch files to create
  9720. animations without the internal loop as you may have done in POV-Ray 2.
  9721.  
  9722. 6.2.1.1          External Animation Loop
  9723.  
  9724.   +Kn.n=n.nSame as Clock=n.nt identifier to n.n
  9725.  
  9726.  
  9727. The Clock=n.n option or the +Kn.n switch may be used to pass a single float
  9728. value to the program for basic animation. The value is stored in the float
  9729. identifier clock. If an object had a rotate <0,clock,0> attached then you
  9730. could rotate the object by different amounts over different frames by setting
  9731. +K10.0, +K20.0... etc. on successive renderings. It is up to the user to
  9732. repeatedly invoke POV-Ray with a different Clock value and a different
  9733. Output_File_Name for each frame.
  9734.  
  9735. 6.2.1.2          Internal Animation Loop
  9736.  
  9737.   +KFn.nClock=n.n.nSame as Final_Clock=n.n.n to n
  9738.  
  9739.  
  9740. The internal animation loop new to POV-Ray 3.0 relieves the user of the task
  9741. of generating complicated sets of batch files to invoke POV-Ray multiple
  9742. times with different settings. While the multitude of options may look
  9743. intimidating, the clever set of default values means that you will probably
  9744. only need to specify the Final_Frame=n or the +KFFn option to specify the
  9745. number of frames. All other values may remain at their defaults.
  9746.  
  9747. Any Final_Frame setting other than -1 will trigger POV-Ray's internal
  9748. animation loop. For example Final_Frame=10 or +KFF10 causes POV-Ray to render
  9749. your scene 10 times. If you specified Output_File_Name=file.tga then each
  9750. frame would be output as file01.tga, file02.tga, file03.tga etc. The number
  9751. of zero-padded digits in the file name depends upon the final frame number.
  9752. For example +KFF100 would generate file001.tga through file100.tga. The frame
  9753. number may encroach upon the file name. On MS-DOS with an eight character
  9754. limit, myscene.pov would render to mysce001.tga through mysce100.tga.
  9755.  
  9756. The default Initial_Frame=1 will probably never have to be changed. You would
  9757. only change it if you were assembling a long animation sequence in pieces.
  9758. One scene might run from frame 1 to 50 and the next from 51 to 100. The
  9759. Initial_Frame=n or +KFIn option is for this purpose.
  9760.  
  9761. Note that if you wish to render a subset of frames such as 30 through 40 out
  9762. of a 1 to 100 animation, you should not change Frame_Initial or Frame_Final.
  9763. Instead you should use the subset commands described in section "Subsets of
  9764. Animation Frames".
  9765.  
  9766. Unlike some animation packages, the action in POV-Ray animated scenes does
  9767. not depend upon the integer frame numbers. Rather you should design your
  9768. scenes based upon the float identifier clock. By default, the clock value is
  9769. 0.0 for the initial frame and 1.0 for the final frame. All other frames are
  9770. interpolated between these values. For example if your object is supposed to
  9771. rotate one full turn over the course of the animation, you could specify
  9772. rotate  360*clock*y. Then as clock runs from 0.0 to 1.0, the object rotates
  9773. about the y-axis from 0 to 360 degrees.
  9774.  
  9775. The major advantage of this system is that you can render a 10 frame
  9776. animation or a 100 frame or 500 frame or 329 frame animation yet you still
  9777. get one full 360 degree rotation. Test renders of a few frames work exactly
  9778. like final renders of many frames.
  9779.  
  9780. In effect you define the motion over a continuous float valued parameter (the
  9781. clock) and you take discrete samples at some fixed intervals (the frames). If
  9782. you take a movie or video tape of a real scene it works the same way. An
  9783. object's actual motion depends only on time. It does not depend on the frame
  9784. rate of your camera.
  9785.  
  9786. Many users have already created scenes for POV-Ray 2 that expect clock values
  9787. over a range other than the default 0.0 to 1.0. For this reason we provide
  9788. the Initial_Clock=n.n or +KIn.n and Final_Clock=n.n or +KFn.n options. For
  9789. example to run the clock from 25.0 to 75.0 you would specify
  9790. Initial_Clock=25.0 and Final_Clock=75.0. Then the clock would be set to 25.0
  9791. for the initial frame and 75.0 for the final frame. In-between frames would
  9792. have clock values interpolated from 25.0 through 75.0 proportionally.
  9793.  
  9794. Users who are accustomed to using frame numbers rather than clock values
  9795. could specify Initial_Clock=1.0 and Final_Clock=10.0 and Frame_Final=10 for a
  9796. 10 frame animation.
  9797.  
  9798. For new scenes, we recommend you do not change the Initial_Clock or
  9799. Final_Clock from their default 0.0 to 1.0 values. If you want the clock to
  9800. vary over a different range than the default 0.0 to 1.0, we recommend you
  9801. handle this inside your scene file as follows...
  9802.  
  9803.   #declare Start    = 25.0
  9804.   #declare End      = 75.0
  9805.   #declare My_Clock = Start+(End-Start)*clock
  9806.  
  9807.  
  9808. Then use My_Clock in the scene description. This keeps the critical values
  9809. 25.0 and 75.0 in your .pov file.
  9810.  
  9811. Note that more details concerning the inner workings of the animation loop
  9812. are in the section on shell-out operating system commands in section
  9813. "Shell-out to Operating System".
  9814.  
  9815. 6.2.1.3          Subsets of Animation Frames
  9816.  
  9817.   +EFn or +EF0.nme=0.n.nSame as Subset_End_Frameme n percentnt
  9818.  
  9819.  
  9820. When creating a long animation, it may be handy to render only a portion of
  9821. the animation to see what it looks like. Suppose you have 100 frames but only
  9822. want to render frames 30 through 40. If you set Initial_Frame=30 and
  9823. Final_Frame=40 then the clock would vary from 0.0 to 1.0 from frames 30
  9824. through 40 rather than 0.30 through 0.40 as it should. Therefore you should
  9825. leave Initial_Frame=1 and Final_Frame=100 and use Subset_Start_Frame=30 and
  9826. Subset_End_Frame=40 to selectively render part of the scene. POV-Ray will
  9827. then properly compute the clock values.
  9828.  
  9829. Usually you will specify the subset using the actual integer frame numbers
  9830. however an alternate form of the subset commands takes a float value in the
  9831. range 0.0 <=n.nnn <=1.0 which is interpreted as a fraction of the whole
  9832. animation. For example, Subset_Start_Frame=0.333 and Subset_End_Frame=0.667
  9833. would render the middle 1/3rd of a sequence regardless of the number of
  9834. frames.
  9835.  
  9836. 6.2.1.4          Cyclic Animation
  9837.  
  9838.   -KClic_Animation=boolTurn cyclic animation offoff
  9839.  
  9840.  
  9841. Many computer animation sequences are designed to be run in a continuous
  9842. loop. Suppose you have an object that rotates exactly 360 degrees over the
  9843. course of your animation and you did rotate  360*clock*y to do so. Both the
  9844. first and last frames would be identical. Upon playback there would be a
  9845. brief one frame jerkiness. To eliminate this problem you need to adjust the
  9846. clock so that the last frame does not match the first. For example a ten
  9847. frame cyclic animation should not use clock 0.0 to 1.0. It should run from
  9848. 0.0 to 0.9 in 0.1 increments. However if you change to 20 frames it should
  9849. run from 0.0 to 0.95 in 0.05 increments. This complicates things because you
  9850. would have to change the final clock value every time you changed
  9851. Final_Frame. Setting Cyclic_Animation=on or using +KC will cause POV-Ray to
  9852. automatically adjust the final clock value for cyclic animation regardless of
  9853. how many total frames. The default value for this setting is off.
  9854.  
  9855. 6.2.1.5          Field Rendering
  9856.  
  9857.   -UO_Field=booloolSet odd field flag offffoff
  9858.  
  9859.  
  9860. Field rendering is sometimes used for animations when the animation is being
  9861. output for television. TVs only display alternate scan lines on each vertical
  9862. refresh. When each frame is being displayed the fields are interlaced to give
  9863. the impression of a higher resolution image. The even scan lines make up the
  9864. even field, and are drawn first (i. e. scan lines 0, 2, 4, etc.), followed by
  9865. the odd field, made up of the odd numbered scan lines are drawn afterwards.
  9866. If objects in an animation are moving quickly, their position can change
  9867. noticeably from one field to the next. As a result, it may be desirable in
  9868. these cases to have POV-Ray render alternate fields at the actual field rate
  9869. (which is twice the frame rate), rather than rendering full frames at the
  9870. normal frame rate. This would save a great deal of time compared to rendering
  9871. the entire animation at twice the frame rate, and then only using half of
  9872. each frame.
  9873.  
  9874. By default, field rendering is not used. Setting Field_Render=on or using +UF
  9875. will cause alternate frames in an animation to be only the even or odd fields
  9876. of an animation. By default, the first frame is the even field, followed by
  9877. the odd field. You can have POV-Ray render the odd field first by specifying
  9878. Odd_Field=on, or by using the +UO switch.
  9879.  
  9880. 6.2.2            Output Options
  9881.  
  9882.  
  9883. 6.2.2.1          General Output Options
  9884.  
  9885.  
  9886. 6.2.2.1.1        Height and Width of Output
  9887.  
  9888.   +Wnth=nnSame as Width=nn (when n > 8)
  9889.  
  9890.  
  9891. These switches set the height and width of the image in pixels. This
  9892. specifies the image size for file output. The preview display, if on, will
  9893. generally attempt to pick a video mode to accommodate this size but the
  9894. display settings do not in any way affect the resulting file output.
  9895.  
  9896. 6.2.2.1.2        Partial Output Options
  9897.  
  9898.   +ER0.n or +E0.nnSame as End_Row=0.nercent of heightthh
  9899.  
  9900.  
  9901. When doing test rendering it is often convenient to define a small,
  9902. rectangular sub-section of the whole screen so you can quickly check out one
  9903. area of the image. The Start_Row, End_Row, Start_Column and End_Column
  9904. options allow you to define the subset area to be rendered. The default
  9905. values are the full size of the image from (1,1) which is the upper left to
  9906. (w,h) on the lower right where w and h are the Width=n and Height=n values
  9907. you have set.
  9908.  
  9909. Note if the number specified is greater than 1 then it is interpreted as an
  9910. absolute row or column number in pixels. If it is a decimal value between 0.0
  9911. and 1.0 then it is interpreted as a percent of the total width or height of
  9912. the image. For example: Start_Row=0.75 and Start_Column=0.75 starts on a row
  9913. 75% down from the top at a column 75% from the left. Thus it renders only the
  9914. lower-right 25% of the image regardless of the specified width and height.
  9915.  
  9916. The +SR, +ER, +SC and +EC switches work in the same way as the corresponding
  9917. INI-style settings for both absolute settings or percentages. Early versions
  9918. of POV-Ray allowed only start and end rows to be specified with +Sn and +En
  9919. so they are still supported in addition to +SR and +ER.
  9920.  
  9921. 6.2.2.1.3        Interrupting Options
  9922.  
  9923.   -Xnt_Abort_Count=nSet to test for abort off (in future test every n pixels)
  9924.  
  9925.  
  9926.  
  9927. On some operating systems once you start a rendering you must let it finish.
  9928. The Test_Abort=on option or +X switch causes POV-Ray to test the keyboard for
  9929. keypress. If you have pressed a key, it will generate a controlled user
  9930. abort. Files will be flushed and closed but only data through the last full
  9931. row of pixels is saved. POV-Ray exits with an error code 2 (normally POV-Ray
  9932. returns 0 for a successful run or 1 for a fatal error).
  9933.  
  9934. When this option is on, the keyboard is polled on every line while parsing
  9935. the scene file and on every pixel while rendering. Because polling the
  9936. keyboard can slow down a rendering, the Test_Abort_Count=n option or +Xn
  9937. switch causes the test to be performed only every n pixels rendered or scene
  9938. lines parsed.
  9939.  
  9940. 6.2.2.1.4        Resuming Options
  9941.  
  9942.   +GIsss_Ini=falseoolSame as Create_Ini=sss previously set file.ini
  9943.  
  9944.  
  9945. If you abort a render while it's in progress or if you used the End_Row
  9946. option to end the render prematurely, you can use Continue_Trace=on or +C
  9947. option to continue the render later at the point where you left off. This
  9948. option reads in the previously generated output file, displays the partial
  9949. image rendered so far, then proceeds with the ray-tracing. This option cannot
  9950. be used if file output is disabled with Output_to_file=off or -F.
  9951.  
  9952. The Continue_Trace option may not work if the Start_Row option has been set
  9953. to anything but the top of the file, depending on the output format being
  9954. used.
  9955.  
  9956. POV-Ray tries to figure out where to resume an interrupted trace by reading
  9957. any previously generated data in the specified output file. All file formats
  9958. contain the image size, so this will override any image size settings
  9959. specified. Some file formats (namely TGA and PNG) also store information
  9960. about where the file started (i. e. +SCn and +SRn options), alpha output +UA,
  9961. and bit-depth +FNn, which will override these settings. It is up to the user
  9962. to make sure that all other options are set the same as the original render.
  9963.  
  9964. The Create_Ini option or +GI switch provides an easy way to create an INI
  9965. file with all of the rendering options, so you can re-run files with the same
  9966. options, or ensure you have all the same options when resuming. This option
  9967. creates an INI file with every option set at the value used for that
  9968. rendering. This includes default values which you have not specified. For
  9969. example if you run POV-Ray with...
  9970.  
  9971.   POVRAY +Isimple.pov MYOPTS +GIrerun.ini MOREOPTS
  9972.  
  9973.  
  9974. POV-Ray will create a file called rerun.ini with all of the options used to
  9975. generate this scene. The file is not written until all options have been
  9976. processed. This means that in the above example, the file will include
  9977. options from both myopts.ini and moreopts.ini despite the fact that the +GI
  9978. switch is specified between them. You may now re-run the scene with...
  9979.  
  9980.   POVRAY RERUN
  9981.  
  9982.  
  9983. or resume an interrupted trace with
  9984.  
  9985.   POVRAY RERUN +C
  9986.  
  9987.  
  9988. If you add other switches with the rerun.ini reference, they will be included
  9989. in future re-runs because the file is re-written every time you use it.
  9990.  
  9991. The Create_Ini option is also useful for documenting how a scene was
  9992. rendered. If you render waycool.pov with Create_Ini=on then it will create a
  9993. file waycool.ini that you could distribute along with your scene file so
  9994. other users can exactly re-create your image.
  9995.  
  9996. 6.2.2.2          Display Output Options
  9997.  
  9998.  
  9999. 6.2.2.2.1        Display Hardware Settings
  10000.  
  10001.   Display_Gamma=n.nSets the display gamma to n.n, palette 'y' in future
  10002.  
  10003.  
  10004. The Display=on or +D switch will turn on the graphics display of the image
  10005. while it is being rendered. Even on some non-graphics systems, POV-Ray may
  10006. display an 80 by 24 character ASCII-Art version of your image. Where
  10007. available, the display may be full, 24-bit true color. Setting Display=off or
  10008. using the -D switch will turn off the graphics display which is the default.
  10009.  
  10010. The Video_Mode=x option sets the display mode or hardware type chosen where x
  10011. is a single digit or letter that is machine dependent (see section "Display
  10012. Types" for a description of the modes supported by the MS-DOS version).
  10013. Generally Video_Mode=0 means the default or an auto-detected setting should
  10014. be used. When using switches, this character immediately follows the switch.
  10015. For example the +D0 switch will turn on the graphics display in the default
  10016. mode.
  10017.  
  10018. The Palette=y option selects the palette to be used. Typically the single
  10019. character parameter y is a digit which selects one of several fixed palettes
  10020. or a letter such G for gray scale, H for 15-bit or 16-bit high color or T for
  10021. 24-bit true color. When using switches, this character is the 2nd character
  10022. after the switch. For example the +D0T switch will turn on the graphics
  10023. display in the default mode with a true color palette.
  10024.  
  10025. The Display_Gamma=n.n setting is new with POV-Ray 3.0, and is not available
  10026. as a command-line switch. The Display_Gamma setting overcomes the problem of
  10027. images (whether ray-traced or not) having different brightness when being
  10028. displayed on different monitors, different video cards, and under different
  10029. operating systems. Note that the Display_Gamma is a setting based on your
  10030. computer's display hardware, and should be set correctly once and not
  10031. changed. The Display_Gamma INI setting works in conjunction with the new
  10032. assumed_gamma global setting to ensure that POV scenes and the images they
  10033. create look the same on all systems. See section "Assumed_Gamma" which
  10034. describes the assumed_gamma global setting and describes gamma more
  10035. thoroughly.
  10036.  
  10037. While the Display_Gamma can be different for each system, there are a few
  10038. general rules that can be used for setting Display_Gamma if you don't know it
  10039. exactly. If the Display_Gamma keyword does not appear in the INI file,
  10040. POV-Ray assumes that the display gamma is 2.2. This is because most PC
  10041. monitors have a gamma value in the range 1.6 to 2.6 (newer models seem to
  10042. have a lower gamma value). MacOS has the ability to do gamma correction
  10043. inside the system software (based on a user setting in the gamma control
  10044. panel). If the gamma control panel is turned off, or is not available, the
  10045. default Macintosh system gamma is 1.8. Some high-end PC graphics cards can do
  10046. hardware gamma correction and should use the current Display_Gamma setting,
  10047. usually 1.0. A gamma test image is also available to help users to set their
  10048. Display_Gamma accurately.
  10049.  
  10050. For scene files that do not contain an assumed_gamma global setting the INI
  10051. file option Display_Gamma will not have any affect on the preview output of
  10052. POV-Ray or for most output file formats. However, the Display_Gamma value is
  10053. used when creating PNG format output files, and also when rendering the
  10054. POV-Ray example files (because they have an assumed_gamma), so it should
  10055. still be correctly set for your system to ensure proper results.
  10056.  
  10057. 6.2.2.2.2        Display Related Settings
  10058.  
  10059.   -UDw_Vistas=boolboolTurn draw vistas offofffoff
  10060.  
  10061.  
  10062. On some systems, when the image is complete, the graphics display is cleared
  10063. and POV-Ray switches back into text mode to print the final statistics and to
  10064. exit. Normally when the graphics display is on, you want to look at the image
  10065. awhile before continuing. Using Pause_When_Done=on or +P causes POV-Ray to
  10066. pause in graphics mode until you to press a key to continue. The default is
  10067. not to pause (-P).
  10068.  
  10069. When the graphics display is not used, it is often desirable to monitor
  10070. progress of the rendering. Using Verbose=on or +V turns on verbose reporting
  10071. of your rendering progress. This reports the number of the line currently
  10072. being rendered, the elapsed time for the current frame and other information.
  10073. On some systems, this textual information can conflict with the graphics
  10074. display. You may need to turn this off when the display is on. The default
  10075. setting is off (-V).
  10076.  
  10077. The option Draw_Vistas=on or +UD was originally a debugging help for
  10078. POV-Ray's vista buffer feature but it was such fun we decided to keep it.
  10079. Vista buffering is a spatial sub-division method that projects the 2-D
  10080. extents of bounding boxes onto the viewing window. POV-Ray tests the 2-D x, y
  10081. pixel location against these rectangular areas to determine quickly which
  10082. objects, if any, the viewing ray will hit. This option shows you the 2-D
  10083. rectangles used. The default setting is off (-UD) because the drawing of the
  10084. rectangles can take considerable time on complex scenes and it serves no
  10085. critical purpose. See section "Automatic Bounding Control" for more details.
  10086.  
  10087. 6.2.2.2.3        Mosaic Preview
  10088.  
  10089.   +EPniew_End_Size=n=nSame as Preview_End_Size=ne to n n
  10090.  
  10091.  
  10092. Typically, while you are developing a scene, you will do many low resolution
  10093. test renders to see if objects are placed properly. Often this low resolution
  10094. version doesn't give you sufficient detail and you have to render the scene
  10095. again at a higher resolution. A feature called mosaic preview solves this
  10096. problem by automatically rendering your image in several passes.
  10097.  
  10098. The early passes paint a rough overview of the entire image using large
  10099. blocks of pixels that look like mosaic tiles. The image is then refined using
  10100. higher resolutions on subsequent passes. This display method very quickly
  10101. displays the entire image at a low resolution, letting you look for any major
  10102. problems with the scene. As it refines the image, you can concentrate on more
  10103. details, like shadows and textures. You don't have to wait for a full
  10104. resolution render to find problems, since you can interrupt the rendering
  10105. early and fix the scene, or if things look good, you can let it continue and
  10106. render the scene at high quality and resolution.
  10107.  
  10108. To use this feature you should first select a width and height value that is
  10109. the highest resolution you will need. Mosaic preview is enabled by specifying
  10110. how big the mosaic blocks will be on the first pass using
  10111. Preview_Start_Size=n or +SPn. The value n should be a number greater than
  10112. zero that is a power of two (1, 2, 4, 8, 16, 32, etc.) If it is not a power
  10113. of two, the nearest power of two less than n is substituted. This sets the
  10114. size of the squares, measured in pixels. A value of 16 will draw every 16th
  10115. pixel as a 16*16 pixel square on the first pass. Subsequent passes will use
  10116. half the previous value (such as 8*8, 4*4 and so on.)
  10117.  
  10118. The process continues until it reaches 1*1 pixels or until it reaches the
  10119. size you set with Preview_End_Size=n or +EPn. Again the value n should be a
  10120. number greater than zero that is a power of two and less than or equal to
  10121. Preview_Start_Size. If it is not a power of two, the nearest power of two
  10122. less than n is substituted. The default ending value is 1. If you set
  10123. Preview_End_Size to a value greater than 1 the mosaic passes will end before
  10124. reaching 1*1, but POV-Ray will always finish with a 1*1. For example, if you
  10125. want a single 8*8 mosaic pass before rendering the final image, set
  10126. Preview_Start_Size=8 and Preview_End_Size=8.
  10127.  
  10128. No file output is performed until the final 1*1 pass is reached. Although the
  10129. preliminary passes render only as many pixels as needed, the 1*1 pass
  10130. re-renders every pixel so that anti-aliasing and file output streams work
  10131. properly. This makes the scene take up to 25% longer than the regular 1*1
  10132. pass to render, so it is suggested that mosaic preview not be used for final
  10133. rendering. Also, the lack of file output until the final pass means that
  10134. renderings which are interrupted before the 1*1 pass can not be resumed
  10135. without starting over from the beginning.
  10136.  
  10137. Future versions of POV-Ray will include some system of temporary files or
  10138. buffers which will eliminate these inefficiencies and limitations. Mosaic
  10139. preview is still a very useful feature for test renderings.
  10140.  
  10141. 6.2.2.3          File Output Options
  10142.  
  10143.   -Ftput_to_File=boolSets file output off(use default type)
  10144.  
  10145.  
  10146. By default, POV-Ray writes an image file to disk. When you are developing a
  10147. scene and doing test renders, the graphic preview may be sufficient. To save
  10148. time and disk activity you may turn file output off with Output_to_File=off
  10149. or -F.
  10150.  
  10151. 6.2.2.3.1        Output File Type
  10152.  
  10153.   -Fxnut_File_Type=xSets file output off; but in future use format 'x', depth
  10154.   Bits_Per_Color=nl Sets file output bits/color to 'n'
  10155.  
  10156.  
  10157. The default type of image file depends on which platform you are using.
  10158. MS-DOS and most others default to 24-bit uncompressed Targa. See your
  10159. platform-specific documentation to see what your default file type is. You
  10160. may select one of several different file types using Output_File_Type=x or
  10161. +Fx where x is one of the following...
  10162.  
  10163.   +FTUncompressed Targa-24 formatPict or Windows BMPoded)
  10164.  
  10165.  
  10166. Note that the obsolete +FD dump format and +FR raw format have been dropped
  10167. from POV-Ray 3.0 because they were rarely used and no longer necessary. PPM,
  10168. PNG, and system specific formats have been added. PPM format images are
  10169. uncompressed, and have a simple text header, which makes it a widely portable
  10170. image format. PNG is a new image format designed not only to replace GIF, but
  10171. to improve on its shortcomings. PNG offers the highest compression available
  10172. without loss for high quality applications, such as ray-tracing. The system
  10173. specific format depends on the platform used and is covered in the
  10174. appropriate system specific documentation.
  10175.  
  10176. Most of these formats output 24 bits per pixel with 8 bits for each of red,
  10177. green and blue data. PNG allows you to optionally specify the output bit
  10178. depth from 5 to 16 bits for each of the red, green, and blue colors, giving
  10179. from 15 to 48 bits of color information per pixel. The default output depth
  10180. for all formats is 8 bits/color (16 million possible colors), but this may be
  10181. changed for PNG format files by setting Bits_Per_Color=n or by specifying
  10182. +FNn, where n is the desired bit depth.
  10183.  
  10184. Specifying a smaller color depth like 5 bits/color (32768 colors) may be
  10185. enough for people with 8- or 16-bit (256 or 65536 color) displays, and will
  10186. improve compression of the PNG file. Higher bit depths like 10 or 12 may be
  10187. useful for video or publishing applications, and 16 bits/color is good for
  10188. grayscale height field output (See section "Height Field" for details on
  10189. height fields).
  10190.  
  10191. Targa format also allows 8 bits of alpha transparency data to be output,
  10192. while PNG format allows 5 to 16 bits of alpha transparency data, depending on
  10193. the color bit depth as specified above. You may turn this option on with
  10194. Output_Alpha=on or +UA. The default is off or -UA. See section "Using the
  10195. Alpha Channel" for further details on transparency.
  10196.  
  10197. In addition to support for variable bit-depths, alpha channel, and grayscale
  10198. formats, PNG files also store the Display_Gamma value so the image displays
  10199. properly on all systems (see section "Display Hardware Settings"). The
  10200. hf_gray_16 global setting, as described in section "HF_Gray_16" will also
  10201. affect the type of data written to the output file.
  10202.  
  10203. 6.2.2.3.2        Output File Name
  10204.  
  10205.   +Ofile_File_Name=fileSame as Output_File_Name=file
  10206.  
  10207.  
  10208. The default output filename is created from the scene name and need not be
  10209. specified. The scene name is the input name with all drive, path, and
  10210. extension information stripped. For example if the input file name is
  10211. c:\povray3\mystuff\myfile.pov the scene name is myfile. The proper extension
  10212. is appended to the scene name based on the file type. For example myfile.tga
  10213. or myfile.png might be used.
  10214.  
  10215. You may override the default output name using Output_File_Name=file or
  10216. +Ofile. For example:
  10217.  
  10218.   Input_File_Name=myinput.pov
  10219.   Output_File_Name=myoutput.tga
  10220.  
  10221.  
  10222. If an output file name of "-" is specified (a single minus sign), then the
  10223. image will be written to standard output, usually the screen. The output can
  10224. then be piped into another program or to a GUI if desired.
  10225.  
  10226. 6.2.2.3.3        Output File Buffer
  10227.  
  10228.   Buffer_Size=n=boolSet output buffer size to 'n' kilobytes. If n is zero, no
  10229.                     buffering. If n < system default, the system default is
  10230.   -Bn               Turn buffer off, but for future set size n
  10231.  
  10232.  
  10233. The Buffer_Output and Buffer_Size options and the +B switch allows you to
  10234. assign large buffers to the output file. This reduces the amount of time
  10235. spent writing to the disk. If this parameter is not specified, then as each
  10236. row of pixels is finished, the line is written to the file and the file is
  10237. flushed. On most systems, this operation ensures that the file is written to
  10238. the disk so that in the event of a system crash or other catastrophic event,
  10239. at least a part of the picture has been stored properly and retrievable on
  10240. disk. The default is not to use any buffer.
  10241.  
  10242. 6.2.2.4          CPU Utilization Histogram
  10243.  
  10244. The CPU utilization histogram is a way of finding out where POV-Ray is
  10245. spending its rendering time, as well as an interesting way of generating
  10246. heightfields. The histogram splits up the screen into a rectangular grid of
  10247. blocks. As POV-Ray renders the image, it calculates the amount of time it
  10248. spends rendering each pixel and then adds this time to the total rendering
  10249. time for each grid block. When the rendering is complete, the histogram is a
  10250. file which represents how much time was spent computing the pixels in each
  10251. grid block.
  10252.  
  10253. Not all versions of POV-Ray allow the creation of histograms. The histogram
  10254. output is dependent on the file type and the system that POV-Ray is being run
  10255. on.
  10256.  
  10257. 6.2.2.4.1        File Type
  10258.  
  10259.   +HTxogram_Type=xSame as Histogram_Type=x(turn off if type is 'X')
  10260.  
  10261.  
  10262. The histogram output file type is nearly the same as that used for the image
  10263. output file types in "Output File Type". The available histogram file types
  10264. are as follows.
  10265.  
  10266.   +HTXNo histogram file output is generatedindows BMPscaleets
  10267.  
  10268.  
  10269. Note that +HTC does not generate a compressed Targa-24 format output file but
  10270. rather a text file with a comma-separated list of the time spent in each grid
  10271. block, in left-to-right and top-to bottom order. The units of time output to
  10272. the CSV file are system dependent. See the system specific documentation for
  10273. further details on the time units in CSV files.
  10274.  
  10275. The Targa and PPM format files are in the POV heightfield format (see "Height
  10276. Field"), so the histogram information is stored in both the red and green
  10277. parts of the image, which makes it unsuitable for viewing. When used as a
  10278. height field, lower values indicate less time spent calculating the pixels in
  10279. that block, while higher indicate more time spent in that block.
  10280.  
  10281. PNG format images are stored as grayscale images and are useful for both
  10282. viewing the histogram data as well as for use as a heightfield. In PNG files,
  10283. the darker (lower) areas indicate less time spent in that grid block, while
  10284. the brighter (higher) areas indicate more time spent in that grid block.
  10285.  
  10286. 6.2.2.4.2        File Name
  10287.  
  10288.   +HNfileam_Name=fileSame as Histogram_Name=file
  10289.  
  10290.  
  10291. The histogram file name is the name of the file in which to write the
  10292. histogram data. If the file name is not specified it will default to
  10293. histgram.ext, where ext is based on the file type specified previously. Note
  10294. that if the histogram name is specified the file name extension should match
  10295. the file type.
  10296.  
  10297. 6.2.2.4.3        Grid Size
  10298.  
  10299.   +HSxx.yym_Grid_Size=xx.yySame as Histogram_Grid_Size=xx.yy
  10300.  
  10301.  
  10302. The histogram grid size gives the number of times the image is split up in
  10303. both the horizontal and vertical directions. For example
  10304.  
  10305.   povray +Isample +W640 +H480 +HTN +HS160.120 +HNhistogrm.png
  10306.  
  10307.  
  10308. will split the image into 160*120 grid blocks, each of size 4*4 pixels, and
  10309. output a PNG file, suitable for viewing or for use as a heightfield. Smaller
  10310. numbers for the grid size mean more pixels are put into the same grid block.
  10311. With CSV output, the number of values output is the same as the number of
  10312. grid blocks specified. For the other formats the image size is identical to
  10313. the rendered image rather than the specified grid size, to allow easy
  10314. comparison between the histogram and the rendered image. If the histogram
  10315. grid size is not specified, it will default to the same size as the image, so
  10316. there will be one grid block per pixel.
  10317.  
  10318. Note that on systems that do task-switching or multi-tasking the histogram
  10319. may not exactly represent the amount of time POV-Ray spent in a given grid
  10320. block since the histogram is based on real time rather than CPU time. As a
  10321. result, time may be spent for operating system overhead or on other tasks
  10322. running at the same time. This will cause the histogram to have speckling,
  10323. noise or large spikes. This can be reduced by decreasing the grid size so
  10324. that more pixels are averaged into a given grid block.
  10325.  
  10326. 6.2.3            Scene Parsing Options
  10327.  
  10328. POV-Ray reads in your scene file and processes it to create an internal model
  10329. of your scene. The process is called parsing. As your file is parsed other
  10330. files may be read along the way. This section covers options concerning what
  10331. to parse, where to find it and what version specific assumptions it should
  10332. make while parsing it.
  10333.  
  10334. 6.2.3.1          Input File Name
  10335.  
  10336.   +IfileFile_Name=fileSame as Input_File_Name=file
  10337.  
  10338.  
  10339. You will probably always set this option but if you do not the default input
  10340. filename is object.pov. If you do not have an extension then .pov is assumed.
  10341. On case-sensitive operating systems both .pov and .POV are tried. A full path
  10342. specification may be used (on MS-DOS systems +Ic:\povray3\mystuff\myfile.pov
  10343. is allowed for example). In addition to specifying the input file name this
  10344. also establishes the scene name.
  10345.  
  10346. The scene name is the input name with drive, path and extension stripped. In
  10347. the above example the scene name is myfile. This name is used to create a
  10348. default output file name and it is referenced other places.
  10349.  
  10350. If you use "-" as the input file name the input will be read from standard
  10351. input. Thus you can pipe a scene created by a program to POV-Ray and render
  10352. it without having a scene file.
  10353.  
  10354. Under MS-DOS you can try this feature by typing.
  10355.  
  10356.   type ANYSCENE.POV | povray +I-
  10357.  
  10358.  
  10359. 6.2.3.2          Library Paths
  10360.  
  10361.   +Lpathy_Path=pathSame as Library_Path=pathry paths
  10362.  
  10363.  
  10364. POV-Ray looks for files in the current directory. If it does not find a file
  10365. it needs it looks in various other library directories which you specify.
  10366. POV-Ray does not search your operating system path. It only searches the
  10367. current directory and directories which you specify with this option. For
  10368. example the standard include files are usually kept in one special directory.
  10369. You tell POV-Ray to look there with...
  10370.  
  10371.   Library_Path=c:\povray3\include
  10372.  
  10373.  
  10374. You must not specify any final path separators ("\" or "/") at the end.
  10375.  
  10376. Multiple uses of this option switch do not override previous settings. Up to
  10377. ten unique paths may be specified. If you specify the exact same path twice
  10378. it is only counts once. The current directory will be searched first followed
  10379. by the indicated library directories in the order in which you specified
  10380. them.
  10381.  
  10382. 6.2.3.3          Language Version
  10383.  
  10384.   +MVn.nn=n.nSame as Version=n.ne compatibility to version n.n
  10385.  
  10386.  
  10387. While many language changes have been made for POV-Ray 3.0, all of version
  10388. 2.0 syntax and most of version 1.0 syntax still works. Whenever possible we
  10389. try to maintain backwards compatibility. One feature introduced in 2.0 that
  10390. was incompatible with any 1.0 scene files is the parsing of float
  10391. expressions. Setting Version=1.0 or using +MV1.0 turns off expression parsing
  10392. as well as many warning messages so that nearly all 1.0 files will still
  10393. work. The changes between 2.0 and 3.0 are not as extensive. Setting
  10394. Version=2.0 is only necessary to eliminate some warning messages. Naturally
  10395. the default setting for this option is Version=3.0.
  10396.  
  10397. The #version language directive can also be used to change modes several
  10398. times within scene files. The above options affect only the initial setting.
  10399. See section "Version Directive" for more details about the language version
  10400. directive.
  10401.  
  10402. 6.2.3.4          Removing User Bounding
  10403.  
  10404.   -SUit_Unions=boollTurn split bounded unions offoffoffoff
  10405.  
  10406.  
  10407. Early versions of POV-Ray had no system of automatic bounding or spatial
  10408. sub-division to speed up ray-object intersection tests. Users had to manually
  10409. create bounding boxes to speed up the rendering. POV-Ray 3.0 has more
  10410. sophisticated automatic bounding than any previous version. In many cases the
  10411. manual bounding on older scenes is slower than the new automatic systems.
  10412. Therefore POV-Ray removes manual bounding when it knows it will help. In rare
  10413. instances you may want to keep manual bounding. Some older scenes incorrectly
  10414. used bounding when they should have used clipping. If POV-Ray removes the
  10415. bounds in these scenes the image will not look right. To turn off the
  10416. automatic removal of manual bounds you should specify Remove_Bounds=off or
  10417. use -UR. The default is Remove_Bounds=on.
  10418.  
  10419. One area where the jury is still out is the splitting of manually bounded
  10420. unions. Unbounded unions are always split into their component parts so that
  10421. automatic bounding works better. Most users do not bound unions because they
  10422. know that doing so is usually slower. If you do manually bound a union we
  10423. presume you really want it bound. For safety sake we do not presume to remove
  10424. such bounds. If you want to remove manual bounds from unions you should
  10425. specify Split_Unions=on or use +SU. The default is Split_Unions=off.
  10426.  
  10427. 6.2.4            Shell-out to Operating System
  10428.  
  10429.   Fatal_Error_Command=sSet command when POV-Ray has fatal error
  10430.  
  10431.  
  10432. Note that no +/- switches are available for these options. They cannot be
  10433. used from the command line. They may only be used from INI files.
  10434.  
  10435. POV-Ray offers you the opportunity to shell-out to the operating system at
  10436. several key points to execute another program or batch file. Usually this is
  10437. used to manage files created by the internal animation loop however the shell
  10438. commands are available for any scene. The CMD is a single line of text which
  10439. is passed to the operating system to execute a program. For example
  10440.  
  10441.   Post_Scene_Command=tga2gif -d -m myfile
  10442.  
  10443.  
  10444. would use the utility tga2gif with the -D and -M parameters to convert
  10445. myfile.tga to myfile.gif after the scene had finished rendering.
  10446.  
  10447. 6.2.4.1          String Substitution in Shell Commands
  10448.  
  10449. It could get cumbersome to change the Post_Scene_Command every time you
  10450. changed scene names. POV-Ray can substitute various values into a CMD string
  10451. for you. For example:
  10452.  
  10453.   Post_Scene_Command=tga2gif -d -m %s
  10454.  
  10455.  
  10456. POV-Ray will substitute the %s with the scene name in the command. The scene
  10457. name is the Input_File_Name or +I setting with any drive, directory or
  10458. extension removed. For example:
  10459.  
  10460.   Input_File_Name=c:\povray3\scenes\waycool.pov
  10461.  
  10462.  
  10463. is stripped down to the scene name waycool which results in...
  10464.  
  10465.   Post_Scene_Command=tga2gif -d -m waycool
  10466.  
  10467.  
  10468. In an animation it may be necessary to have the exact output file name with
  10469. the frame number included. The string %o will substitute the output file
  10470. name. Suppose you want to save your output files in a zip archive using
  10471. pkzip. You could do...
  10472.  
  10473.   Post_Frame_Command=pkzip -m %s %o
  10474.  
  10475.  
  10476. After rendering frame 12 of myscene.pov POV-Ray would shell to the operating
  10477. system with "pkzip -m myscene mysce012.tga". The -M switch in pkzip moves
  10478. mysce012.tga to myscene.zip and removes it from the directory. Note that %o
  10479. includes frame numbers only when in an animation loop. During the
  10480. Pre_Scene_Command and Post_Scene_Command there is no frame number so the
  10481. original, unnumbered Output_File_Name is used. Any User_Abort_Command or
  10482. Fatal_Error_Command not inside the loop will similarly give an unnumbered %o
  10483. substitution.
  10484.  
  10485. Here is the complete list of substitutions available for a common string.
  10486.  
  10487.  
  10488. 6.2.4.2          Shell Command Sequencing
  10489.  
  10490. Here is the sequence of events in an animation loop. Non-animated scenes work
  10491. the exact same way except there is no loop.
  10492.  
  10493.   1)  Process all INI file keywords and command line switches just once.
  10494.   2)  Open any text output streams and do Create_INI if any.
  10495.   3)  Execute Pre_Scene_Command if any.
  10496.   4)  Loop through frames (or just do once on non-animation).
  10497.       a)  Execute Pre_Frame_Command if any.
  10498.       b)  Parse entire scene file, open output file and read settings,
  10499.           turn on display, render the frame, destroy all objects,
  10500.           textures etc., close output file, close display.
  10501.       c)  Execute Post_Frame_Command if any.
  10502.       d)  Go back to 4 a until all frames are done.
  10503.   5)  Execute Post_Scene_Command if any.
  10504.   6)  Exit POV-Ray.
  10505.  
  10506.  
  10507. If the user interrupts processing the User_Abort_Command, if any, is
  10508. executed. User aborts can only occur during the parsing and rendering parts
  10509. of step 4 a above.
  10510.  
  10511. If a fatal error occurs that POV-Ray notices the Fatal_Error_Command, if any,
  10512. is executed. Sometimes an unforeseen bug or memory error could cause a total
  10513. crash of the program in which case there is no chance to shell out. Fatal
  10514. errors can occur just about anywhere including during the processing of
  10515. switches or INI files. If a fatal error occurs before POV-Ray has read the
  10516. Fatal_Error_Command string then obviously no shell can occur.
  10517.  
  10518. Note that the entire scene is re-parsed for every frame. Future versions of
  10519. POV-Ray may allow you to hold over parts of a scene from one frame to the
  10520. next but for now it starts from scratch every time. Note also that the
  10521. Pre_Frame_Command occurs before the scene is parsed. You might use this to
  10522. call some custom scene generation utility before each frame. This utility
  10523. could rewrite your .pov or .inc files if needed. Perhaps you will want to
  10524. generate new .gif or .tga files for image maps or height fields on each
  10525. frame.
  10526.  
  10527. 6.2.4.3          Shell Command Return Actions
  10528.  
  10529.   Fatal_Error_Return=sSet fatal return actionstions
  10530.  
  10531.  
  10532. Note that no +/- switches are available for these options. They cannot be
  10533. used from the command line. They may only be used from INI files.
  10534.  
  10535. Most operating systems allow application programs to return an error code if
  10536. something goes wrong. When POV-Ray executes a shell command it can make use
  10537. of this error code returned from the shell process and take some appropriate
  10538. action if the code is zero or non-zero. POV-Ray itself returns such codes. It
  10539. returns 0 for success, 1 for fatal error and 2 for user abort.
  10540.  
  10541. The actions are designated by a single letter in the different ..._Return=s
  10542. options. The possible actions are:
  10543.  
  10544.   F generate a fatal error in POV-Ray
  10545.  
  10546.  
  10547. For example if your Pre_Frame_Command calls a program which generates your
  10548. height field data and that utility fails then it will return a non-zero code.
  10549. We would probably want POV-Ray to abort as well. The option
  10550. Pre_Frame_Return=F will cause POV-Ray to do a fatal abort if the
  10551. Pre_Frame_Command returns a non-zero code.
  10552.  
  10553. Sometimes a non-zero code from the external process is a good thing. Suppose
  10554. you want to test if a frame has already been rendered. You could use the S
  10555. action to skip this frame if the file is already rendered. Most utilities
  10556. report an error if the file is not found. For example the command pkzip -V
  10557. myscene mysce012.tga tells pkzip you want to view the catalog of myscene.zip
  10558. for the file mysce012.tga. If the file isn't in the archive pkzip returns a
  10559. non-zero code.
  10560.  
  10561. However we want to skip if the file is found. Therefore we need to reverse
  10562. the action so it skips on zero and doesn't skip on non-zero. To reverse the
  10563. zero vs. non-zero triggering of an action precede it with a "-" sign (note a
  10564. "!" will also work since it is used in many programming languages as a negate
  10565. operator).
  10566.  
  10567. Pre_Frame_Return=S will skip if the code shows error (non-zero) and will
  10568. proceed normally on no error (zero). Pre_Frame_Return=-S will skip if there
  10569. is no error (zero) and will proceed normally if there is an error (non-zero).
  10570.  
  10571.  
  10572. The default for all shells is I which means that the return action is ignored
  10573. no matter what. POV-Ray simply proceeds with whatever it was doing before the
  10574. shell command. The other actions depend upon the context. You may want to
  10575. refer back to the animation loop sequence chart in the previous section. The
  10576. action for each shell is as follows.
  10577.  
  10578. On return from any User_Abort_Command if there is an action triggered and you
  10579. have specified...
  10580.  
  10581.   F            then turn this user abort into a fatal error. Do the
  10582.   S, A, Q, or Uthen proceed with the user abort. Exit POV-Ray with error code
  10583. 2.
  10584.  
  10585.  
  10586. On return from any Fatal_Error_Command proceed with the fatal error no matter
  10587. what. Exit POV-Ray with error code 1. On return from any Pre_Scene_Command,
  10588. Pre_Frame_Command, Post_Frame_Command or Post_Scene_Commands if there is an
  10589. action triggered and you have specified...
  10590.  
  10591.   F then generate a fatal error. Do the Fatal_Error_Command, if any. Exit
  10592.   U then generate a user abort. Do the User_Abort_Command, if any. Exit
  10593.   Q then quit POV-Ray immediately. Acts as though POV-Ray never really ran.
  10594.     Do no further shells, (not even Post_Scene_Command) and exit POV-Ray with
  10595.     an error code 0.
  10596.  
  10597.  
  10598. On return from a Pre_Scene_Command if there is an action triggered and you
  10599. have specified...
  10600.  
  10601.   S then skip rendering all frames. Acts as though the scene completed all
  10602.     frames normally. Do not do any Pre_Frame_Command or Post_Frame_Commands.
  10603.     Do the Post_Scene_Command, if any. Exit POV-Ray with error code 0. On the
  10604.   A then skip all scene activity. Works exactly like Q quit. On the earlier
  10605.     chart this means skip to step #6.
  10606.  
  10607.  
  10608. On return from a Pre_Frame_Command if there is an action triggered and you
  10609. have specified...
  10610.  
  10611.   S then skip only this frame. Acts as though this frame never existed. Do
  10612.     not do the Post_Frame_Command. Proceed with the next frame. On the
  10613.     earlier chart this means skip steps #4b and #4c but loop back as needed
  10614.   A then skip rendering this frame and all remaining frames. Acts as though
  10615.     the scene completed all frames normally. Do not do any further
  10616.     Post_Frame_Commands. Do the Post_Scene_Command, if any. Exit POV-Ray with
  10617.     error code 0. On the earlier chart this means skip the rest of step #4
  10618.     and proceed at step #5.
  10619.  
  10620.  
  10621. On return from a Post_Frame_Command if there is an action triggered and you
  10622. have specified...
  10623.  
  10624.   S then skip rendering all remaining frames. Acts as though the scene
  10625.     completed all frames normally. Do the Post_Scene_Command, if any. Exit
  10626.     POV-Ray with error code 0. On the earlier chart this means skip the rest
  10627.   A same as S for this shell command..
  10628.  
  10629.  
  10630. On return from any Post_Scene_Command if there is an action triggered and you
  10631. have specified...
  10632.  
  10633.  
  10634. 6.2.5            Text Output
  10635.  
  10636. Text output is an important way that POV-Ray keeps you informed about what it
  10637. is going to do, what it is doing and what it did. New to POV-Ray 3.0, the
  10638. program splits its text messages into 7 separate streams. Some versions of
  10639. POV-Ray color codes the various types of text. Some versions allow you to
  10640. scroll back several pages of messages. All versions allow you to turn some of
  10641. these text streams off/on or to direct a copy of the text output to one or
  10642. several files. This section details the options which give you control over
  10643. text output.
  10644.  
  10645. 6.2.5.1          Text Streams
  10646.  
  10647. There are seven distinct text streams that POV-Ray uses for output. On some
  10648. versions each stream is designated by a particular color. Text from these
  10649. streams are displayed whenever it is appropriate so there is often an
  10650. intermixing of the text. The distinction is only important if you choose to
  10651. turn some of the streams off or to direct some of the streams to text files.
  10652. On some systems you may be able to review the streams separately in their own
  10653. scroll-back buffer.
  10654.  
  10655. Here is a description of each stream.
  10656.  
  10657. BANNER: This stream displays the program's sign-on banner, copyright,
  10658. contributor's list, and some help screens. It cannot be turned off or
  10659. directed to a file because most of this text is displayed before any options
  10660. or switches are read. Therefore you cannot use an option or switch to control
  10661. it. There are switches which display the help screens. They are covered in
  10662. section "Help Screen Switches".
  10663.  
  10664. DEBUG: This stream displays debugging messages. It was primarily designed for
  10665. developers but this and other streams may also be used by the user to display
  10666. messages from within their scene files. See section "Text Message Streams"
  10667. for details on this feature. This stream may be turned off and/or directed to
  10668. a text file.
  10669.  
  10670. FATAL: This stream displays fatal error messages. After displaying this text,
  10671. POV-Ray will terminate. When the error is a scene parsing error, you may be
  10672. shown several lines of scene text that leads up to the error. This stream may
  10673. be turned off and/or directed to a text file.
  10674.  
  10675. RENDER: This stream displays information about what options you have
  10676. specified to render the scene. It includes feedback on all of the major
  10677. options such as scene name, resolution, animation settings, anti-aliasing and
  10678. others. This stream may be turned off and/or directed to a text file.
  10679.  
  10680. STATISTICS: This stream displays statistics after a frame is rendered. It
  10681. includes information about the number of rays traced, the length of time of
  10682. the processing and other information. This stream may be turned off and/or
  10683. directed to a text file.
  10684.  
  10685. STATUS: This stream displays one-line status messages that explain what
  10686. POV-Ray is doing at the moment. On some systems this stream is displayed on a
  10687. status line at the bottom of the screen. This stream cannot be directed to a
  10688. file because there is generally no need to. The text displayed by the Verbose
  10689. option or +V switch is output to this stream so that part of the status
  10690. stream may be turned off.
  10691.  
  10692. WARNING: This stream displays warning messages during the parsing of scene
  10693. files and other warnings. Despite the warning, POV-Ray can continue to render
  10694. the scene. You will be informed if POV-Ray has made any assumptions about
  10695. your scene so that it can proceed. In general any time you see a warning, you
  10696. should also assume that this means that future versions of POV-Ray will not
  10697. allow the warned action. Therefore you should attempt to eliminate warning
  10698. messages so your scene will be able to run in future versions of POV-Ray.
  10699. This stream may be turned off and/or directed to a text file.
  10700.  
  10701. 6.2.5.2          Console Text Output
  10702.  
  10703.   All_Console=boolboololTurn on/off all debug, fatal, render, statistic and
  10704.   -GA                   Same as All_Console=Off.
  10705.  
  10706.  
  10707. You may suppress the output to the console of the Debug, Fatal, Render,
  10708. Statistic or Warning text streams. For example the Statistic_Console=off
  10709. option or the -GS switch can turn off the Statistic stream. Using on or +GS
  10710. you may turn it on again. You may also turn all five of these streams on or
  10711. off at once using the All_Console option or +GA switch.
  10712.  
  10713. Note that these options take effect immediately when specified. Obviously any
  10714. Error or Warning messages that might occur before the option is read are not
  10715. be affected.
  10716.  
  10717. 6.2.5.3          Directing Text Streams to Files
  10718.  
  10719.   All_File=truefileeeeEcho all debug, fatal, render, statistic and warning
  10720.   All_File=false      Turn off file output of all debug, fatal, render,
  10721.   All_File=file       Echo all debug, fatal, render, statistic and warning
  10722.   -GAfile             Both All_Console=Off, All_File=file
  10723.  
  10724.  
  10725. You may direct a copy of the text streams to a text file for the Debug,
  10726. Fatal, Render, Statistic or Warning text streams. For example the
  10727. Statistic_File=s option or the +GSs switch. If the string s is true or any of
  10728. the other valid true strings then that stream is redirected to a file with a
  10729. default name. Valid true values are true, yes, on or 1. If the value is false
  10730. the direction to a text file is turned off. Valid false values are false, no,
  10731. off or 0. Any other string specified turns on file output and the string is
  10732. interpreted as the output file name.
  10733.  
  10734. Similarly you may specify such a true, false or file name string after a
  10735. switch such as +GSfile. You may also direct all five streams to the same file
  10736. using the All_File option or +GA switch. You may not specify the same file
  10737. for two or more streams because POV-Ray will fail when it tries to open or
  10738. close the same file twice.
  10739.  
  10740. Note that these options take effect immediately when specified. Obviously any
  10741. Error or Warning messages that might occur before the option is read will not
  10742. be affected.
  10743.  
  10744. 6.2.5.4          Help Screen Switches
  10745.  
  10746.   +?0 to +?8Same as +H0 to +H8 to 8 if this is the only switch
  10747.  
  10748.  
  10749. Note that there are no INI style equivalents to these options.
  10750.  
  10751. Graphical interface versions of POV-Ray such as Mac or Windows have extensive
  10752. online help. Other versions of POV-Ray have only a few quick-reference help
  10753. screens. The +? switch, optionally followed by a single digit from 0 to 8,
  10754. will display these help screens to the Banner text stream. After displaying
  10755. the help screens, POV-Ray terminates. Because some operating systems do not
  10756. permit a question mark as a command line switch you may also use the +H
  10757. switch. Note however that this switch is also used to specify the height of
  10758. the image in pixels. Therefore the +H switch is only interpreted as a help
  10759. switch if it is the only switch on the command line and if the value after
  10760. the switch is less than or equal to 8.
  10761.  
  10762. 6.2.6            Tracing Options
  10763.  
  10764. There is more than one way to trace a ray. Sometimes there is a trade-off
  10765. between quality and speed. Sometimes options designed to make tracing faster
  10766. can slow things down. This section covers options that tell POV-Ray how to
  10767. trace rays with the appropriate speed and quality settings.
  10768.  
  10769. 6.2.6.1          Quality Settings
  10770.  
  10771.   +Qnlity=nSame as Quality=n to n (0 <= n <= 11)
  10772.  
  10773.  
  10774. The Quality=n option or +Qn switch allows you to specify the image rendering
  10775. quality. You may choose to lower the quality for test rendering and raise it
  10776. for final renders. The quality adjustments are made by eliminating some of
  10777. the calculations that are normally performed. For example settings below 4 do
  10778. not render shadows. Settings below 8 do not use reflection or refraction. The
  10779. values correspond to the following quality levels:
  10780.  
  10781.   0,1Just show quick colors. Use full ambient lighting only. Quick colors are
  10782.   4,3Render shadows, but no extended lights. 5 Render shadows, including
  10783.   9,7Compute halos.ted, refracted, and transmitted rays.
  10784.  
  10785.  
  10786. 6.2.6.2          Radiosity Setting
  10787.  
  10788.   +QRTurns radiosity on -QR Turns radiosity on
  10789.  
  10790.  
  10791. Radiosity is an additional calculation which computes diffuse
  10792. inter-reflection. It is an extremely slow calculation that is somewhat
  10793. experimental. The parameters which control how radiosity calculations are
  10794. performed are specified in the radiosity section of the global_settings
  10795. statement. See section "Radiosity" for further details.
  10796.  
  10797. 6.2.6.3          Automatic Bounding Control
  10798.  
  10799.   -UVta_Buffer=boold=nTurn vista buffer offoffuture threshold to n
  10800.  
  10801.  
  10802. POV-Ray uses a variety of spatial sub-division systems to speed up ray-object
  10803. intersection tests. The primary system uses a hierarchy of nested bounding
  10804. boxes. This system compartmentalizes all finite objects in a scene into
  10805. invisible rectangular boxes that are arranged in a tree-like hierarchy.
  10806. Before testing the objects within the bounding boxes the tree is descended
  10807. and only those objects are tested whose bounds are hit by a ray. This can
  10808. greatly improve rendering speed. However for scenes with only a few objects
  10809. the overhead of using a bounding system is not worth the effort. The
  10810. Bounding=off option or -MB switch allows you to force bounding off. The
  10811. default value is on.
  10812.  
  10813. The Bounding_Threshold=n or +MBn switch allows you to set the minimum number
  10814. of objects necessary before bounding is used. The default is +MB25 which
  10815. means that if your scene has fewer than 25 objects POV-Ray will automatically
  10816. turn bounding off because the overhead isn't worth it. Generally it's a good
  10817. idea to use a much lower threshold like +MB5.
  10818.  
  10819. Additionally POV-Ray uses systems known as vista buffers and light buffers to
  10820. further speed things up. These systems only work when bounding is on and when
  10821. there are a sufficient number of objects to meet the bounding threshold. The
  10822. vista buffer is created by projecting the bounding box hierarchy onto the
  10823. screen and determining the rectangular areas that are covered by each of the
  10824. elements in the hierarchy. Only those objects whose rectangles enclose a
  10825. given pixel are tested by the primary viewing ray. The vista buffer can only
  10826. be used with perspective and orthographic cameras because they rely on a
  10827. fixed viewpoint and a reasonable projection (i. e. straight lines have to
  10828. stay straight lines after the projection).
  10829.  
  10830. The light buffer is created by enclosing each light source in an imaginary
  10831. box and projecting the bounding box hierarchy onto each of its six sides.
  10832. Since this relies on a fixed light source, light buffers will not be used for
  10833. area lights.
  10834.  
  10835. Reflected and transmitted rays do not take advantage of the light and vista
  10836. buffer.
  10837.  
  10838. The default settings are Vista_Buffer=on or +UV and Light_Buffer=on or +UL.
  10839. The option to turn these features off is available to demonstrate their
  10840. usefulness and as protection against unforeseen bugs which might exist in any
  10841. of these bounding systems.
  10842.  
  10843. In general, any finite object and many types of CSG of finite objects will
  10844. properly respond to this bounding system. In addition blobs and meshes use an
  10845. additional internal bounding system. These systems are not affected by the
  10846. above switch. They can be switched off using the appropriate syntax in the
  10847. scene file (see "Blob" and "Mesh" for details). Text objects are split into
  10848. individual letters that are bounded using the bounding box hierarchy. Some
  10849. CSG combinations of finite and infinite objects are also automatically bound.
  10850. The end result is that you will rarely need to add manual bounding objects as
  10851. was necessary in earlier versions of POV-Ray unless you use many infinite
  10852. objects.
  10853.  
  10854. 6.2.6.4          Anti-Aliasing Options
  10855.  
  10856.   Jitter_Amount=n.nld=n.nSets aa-jitter amount to n.n. If n.n <= 0 aa-jitter
  10857.   +Jn.n                  Sets aa-jitter on; jitter amount to n.n. If n.n <= 0
  10858.   +Rnialias_Depth=n      Same as Antialias_Depth=n9)amount n.n in future)
  10859.  
  10860.  
  10861. The ray-tracing process is in effect a discrete, digital sampling of the
  10862. image with typically one sample per pixel. Such sampling can introduce a
  10863. variety of errors. This includes a jagged, stair-step appearance in sloping
  10864. or curved lines, a broken look for thin lines, moire patterns of interference
  10865. and lost detail or missing objects, which are so small they reside between
  10866. adjacent pixels. The effect that is responsible for those errors is called
  10867. aliasing.
  10868.  
  10869. Anti-aliasing is any technique used to help eliminate such errors or to
  10870. reduce the negative impact they have on the image. In general, anti-aliasing
  10871. makes the ray-traced image look smoother. The Antialias=on option or +A
  10872. switch turns on POV-Ray's anti-aliasing system.
  10873.  
  10874. When anti-aliasing is turned on, POV-Ray attempts to reduce the errors by
  10875. shooting more than one viewing ray into each pixel and averaging the results
  10876. to determine the pixel's apparent color. This technique is called
  10877. super-sampling and can improve the appearance of the final image but it
  10878. drastically increases the time required to render a scene since many more
  10879. calculations have to be done.
  10880.  
  10881. POV-Ray gives you the option to use one of two alternate super-sampling
  10882. methods. The Sampling_Method=n option or +AMn switch selects non-adaptive
  10883. super-sampling (method 1) or adaptive super-sampling (method 2). Selecting
  10884. one of those methods does not turn anti-aliasing on. This has to be done by
  10885. using the +A command line switch or Antialias=on option.
  10886.  
  10887. In the default, non-adaptive method (+AM1), POV-Ray initially traces one ray
  10888. per pixel. If the color of a pixel differs from its neighbors (to the left or
  10889. above) by more than a threshold value then the pixel is super-sampled by
  10890. shooting a given, fixed number of additional rays. The default threshold is
  10891. 0.3 but it may be changed using the Antialias_Threshold=n.n option. When the
  10892. switches are used, the threshold may optionally follow the +A. For example
  10893. +A0.1 turns anti-aliasing on and sets the threshold to 0.1.
  10894.  
  10895. The threshold comparison is computed as follows. If r_1, g_1, b_1 and r_2,
  10896. g_2, b_2 are the rgb components of two pixels then the difference between
  10897. pixels is computed by
  10898.  
  10899.   diff = abs(r1-r2) + abs(g1-g2) + abs(b1-b2).
  10900.  
  10901.  
  10902. If this difference is greater than the threshold both pixels are
  10903. super-sampled. The rgb values are in the range from 0.0 to 1.0 thus the most
  10904. two pixels can differ is 3.0. If the anti-aliasing threshold is 0.0 then
  10905. every pixel is super-sampled. If the threshold is 3.0 then no anti-aliasing
  10906. is done. Lower threshold means more anti-aliasing and less speed. Use
  10907. anti-aliasing for your final version of a picture, not the rough draft. The
  10908. lower the contrast, the lower the threshold should be. Higher contrast
  10909. pictures can get away with higher tolerance values. Good values seem to be
  10910. around 0.2 to 0.4.
  10911.  
  10912. When using the non-adaptive method, the default number of super-samples is
  10913. nine per pixel, located on a 3*3 grid. The Antialias_Depth=n option or +Rn
  10914. switch controls the number of rows and columns of samples taken for a
  10915. super-sampled pixel. For example +R4 would give 4*4=16 samples per pixel.
  10916.  
  10917. The second, adaptive super-sampling method starts by tracing four rays at the
  10918. corners of each pixel. If the resulting colors differ more than the threshold
  10919. amount additional samples will be taken. This is done recursively, i. e. the
  10920. pixel is divided into four sub-pixels that are separately traced and tested
  10921. for further subdivision. The advantage of this method is the reduced number
  10922. of rays that have to be traced. Samples that are common among adjacent pixels
  10923. and sub-pixels are stored and reused to avoid re-tracing of rays. The
  10924. recursive character of this method makes it adaptive, i. e. the
  10925. super-sampling concentrates on those parts of the pixel that are more likely
  10926. to need super-sampling (see figure below).
  10927.  
  10928. Example of how the adapative super-sampling works.
  10929.  
  10930. The maximum number of subdivisions is specified by the Antialias_Depth=n
  10931. option or +Rn switch. This is different from the non-adaptive method were the
  10932. total number of super-samples is specified. A maximum number of n
  10933. subdivisions results in a maximum number of samples per pixel that is given
  10934. by the following table.
  10935.  
  10936.       Number of samples per    Maximum number of samples
  10937.       super-sampled pixel for  per super-sampled pixel for
  10938.  +Rn  the non-adaptive method  the adaptive method
  10939.   1                1                       9
  10940.   2                4                      25
  10941.   3                9                      81
  10942.   4               16                     289
  10943.   5               25                    1089
  10944.   6               36                    4225
  10945.   7               49                   16641
  10946.   8               64                   66049
  10947.   9               81                  263169
  10948.  
  10949.  
  10950. You should note that the maximum number of samples in the adaptive case is
  10951. hardly ever reached for a given pixel. If the adaptive method is used with no
  10952. anti-aliasing each pixel will be the average of the rays traced at its
  10953. corners. In most cases a recursion level of three is sufficient.
  10954.  
  10955. Another way to reduce aliasing artifacts is to introduce noise into the
  10956. sampling process. This is called jittering and works because the human visual
  10957. system is much more forgiving to noise than it is to regular patterns. The
  10958. location of the super-samples is jittered or wiggled a tiny amount when
  10959. anti-aliasing is used. Jittering is used by default but it may be turned off
  10960. with the Jitter=off option or -J switch. The amount of jittering can be set
  10961. with the Jitter_Amount=n.n option. When using switches the jitter scale may
  10962. be specified after the +J switch. For example +J0.5 uses half the normal
  10963. jitter. The default amount of 1.0 is the maximum jitter which will insure
  10964. that all super-samples remain inside the original pixel. Note that the
  10965. jittering noise is random and non-repeatable so you should avoid using jitter
  10966. in animation sequences as the anti-aliased pixels will vary and flicker
  10967. annoyingly from frame to frame.
  10968.  
  10969. If anti-aliasing is not used one sample per pixel is taken regardless of the
  10970. super-sampling method specified.
  10971.  
  10972. 7                Scene Description Language
  10973.  
  10974. The Scene Description Language allows you to describe the world in a readable
  10975. and convenient way. Files are created in plain ASCII text using an editor of
  10976. your choice. The input file name is specified using the Input_File_Name=file
  10977. option or +Ifile switch. By default the files have the extension .pov.
  10978. POV-Ray reads the file, processes it by creating an internal model of the
  10979. scene and then renders the scene.
  10980.  
  10981. The overall syntax of a scene is a file that contains any number of the
  10982. following items in any order.
  10983.  
  10984.    LANGUAGE_DIRECTIVES
  10985.    camera { CAMERA_ITEMS }
  10986.    OBJECT_STATEMENTS
  10987.    ATMOSPHERE_STATEMENTS
  10988.    global_settings { GLOBAL_ITEMS }
  10989.  
  10990.  
  10991. See section "Language Directives", section "Objects", section "Camera",
  10992. section "Atmospheric Effects" and section "Global Settings" for details.
  10993.  
  10994. 7.1              Language Basics
  10995.  
  10996. The POV-Ray language consists of identifiers, reserved keywords, floating
  10997. point expressions, strings, special symbols and comments. The text of a
  10998. POV-Ray scene file is free format. You may put statements on separate lines
  10999. or on the same line as you desire. You may add blank lines, spaces or
  11000. indentations as long as you do not split any keywords or identifiers.
  11001.  
  11002. 7.1.1            Identifiers and Keywords
  11003.  
  11004. POV-Ray allows you to define identifiers for later use in the scene file. An
  11005. identifier may be 1 to 40 characters long. It may consist of upper or lower
  11006. case letters, the digits 0 through 9 or an underscore character ("_"). The
  11007. first character must be an alphabetic character. The declaration of
  11008. identifiers is covered later.
  11009.  
  11010. POV-Ray has a number of reserved keywords which are listed below.
  11011.  
  11012.  
  11013. aa_level                 fog_offset           reciprocal
  11014. aa_threshold             fog_type             recursion_limit
  11015. abs                      frequency            red
  11016. acos                     gif                  reflection
  11017. acosh                    global_settings      refraction
  11018. adaptive                 glowing              render
  11019. adc_bailout              gradient             repeat
  11020. agate                    granite              rgb
  11021. agate_turb               gray_threshold       rgbf
  11022. all                      green                rgbft
  11023. alpha                    halo                 rgbt
  11024. ambient                  height_field         right
  11025. ambient_light            hexagon              ripples
  11026. angle                    hf_gray_16           rotate
  11027. aperture                 hierarchy            roughness
  11028. arc_angle                hollow               samples
  11029. area_light               hypercomplex         scale
  11030. asc                      if                   scallop_wave
  11031. asin                     ifdef                scattering
  11032. asinh                    iff                  seed
  11033. assumed_gamma            image_map            shadowless
  11034. atan                     incidence            sin
  11035. atan2                    include              sine_wave
  11036. atanh                    int                  sinh
  11037. atmosphere               interpolate          sky
  11038. atmospheric_attenuation  intersection         sky_sphere
  11039. attenuating              inverse              slice
  11040. average                  ior                  slope_map
  11041. background               irid                 smooth
  11042. bicubic_patch            irid_wavelength      smooth_triangle
  11043. black_hole               jitter               sor
  11044. blob                     julia_fractal        specular
  11045. blue                     lambda               sphere
  11046. blur_samples             lathe                spherical_mapping
  11047. bounded_by               leopard              spiral
  11048. box                      light_source         spiral1
  11049. box_mapping              linear               spiral2
  11050. bozo                     linear_spline        spotlight
  11051. break                    linear_sweep         spotted
  11052. brick                    location             sqr
  11053. brick_size               log                  sqrt
  11054. brightness               looks_like           statistics
  11055. brilliance               look_at              str
  11056. bumps                    low_error_factor     strcmp
  11057. bumpy1                   mandel               strength
  11058. bumpy2                   map_type             strlen
  11059. bumpy3                   marble               strlwr
  11060. bump_map                 material_map         strupr
  11061. bump_size                matrix               sturm
  11062. camera                   max                  substr
  11063. case                     max_intersections    superellipsoid
  11064. caustics                 max_iteration        switch
  11065. ceil                     max_trace_level      sys
  11066. checker                  max_value            t
  11067. chr                      merge                tan
  11068. clipped_by               mesh                 tanh
  11069. clock                    metallic             test_camera_1
  11070. color                    min                  test_camera_2
  11071. color_map                minimum_reuse        test_camera_3
  11072. colour                   mod                  test_camera_4
  11073. colour_map               mortar               text
  11074. component                nearest_count        texture
  11075. composite                no                   texture_map
  11076. concat                   normal               tga
  11077. cone                     normal_map           thickness
  11078. confidence               no_shadow            threshold
  11079. conic_sweep              number_of_waves      tightness
  11080. constant                 object               tile2
  11081. control0                 octaves              tiles
  11082. control1                 off                  torus
  11083. cos                      offset               track
  11084. cosh                     omega                transform
  11085. count                    omnimax              translate
  11086. crackle                  on                   transmit
  11087. crand                    once                 triangle
  11088. cube                     onion                triangle_wave
  11089. cubic                    open                 true
  11090. cubic_spline             orthographic         ttf
  11091. cylinder                 panoramic            turbulence
  11092. cylindrical_mapping      pattern1             turb_depth
  11093. debug                    pattern2             type
  11094. declare                  pattern3             u
  11095. default                  perspective          ultra_wide_angle
  11096. degrees                  pgm                  union
  11097. dents                    phase                up
  11098. difference               phong                use_color
  11099. diffuse                  phong_size           use_colour
  11100. direction                pi                   use_index
  11101. disc                     pigment              u_steps
  11102. distance                 pigment_map          v
  11103. distance_maximum         planar_mapping       val
  11104. div                      plane                variance
  11105. dust                     png                  vaxis_rotate
  11106. dust_type                point_at             vcross
  11107. eccentricity             poly                 vdot
  11108. else                     polygon              version
  11109. emitting                 pot                  vlength
  11110. end                      pow                  vnormalize
  11111. error                    ppm                  volume_object
  11112. error_bound              precision            volume_rendered
  11113. exp                      prism                vol_with_light
  11114. exponent                 pwr                  vrotate
  11115. fade_distance            quadratic_spline     v_steps
  11116. fade_power               quadric              warning
  11117. falloff                  quartic              warp
  11118. falloff_angle            quaternion           water_level
  11119. false                    quick_color          waves
  11120. file_exists              quick_colour         while
  11121. filter                   quilted              width
  11122. finish                   radial               wood
  11123. fisheye                  radians              wrinkles
  11124. flatness                 radiosity            x
  11125. flip                     radius               y
  11126. floor                    rainbow              yes
  11127. focal_point              ramp_wave            z
  11128. fog                      rand
  11129.  
  11130. fog_alt                  range
  11131.  
  11132.  
  11133. All reserved words are fully lower case. Therefore it is recommended
  11134. that your identifiers contain at least one upper case character so it
  11135. is sure to avoid conflict with reserved words.
  11136.  
  11137. The following keywords are in the above list of reserved keywords but
  11138. are not currently used by POV-Ray however they remain reserved.
  11139.  
  11140.   bumpy1               test_camera_1
  11141.   bumpy2               test_camera_2
  11142.   bumpy3               test_camera_3
  11143.   incidence            test_camera_4
  11144.   pattern1             track
  11145.   pattern2             volume_object
  11146.   pattern3             volume_rendered
  11147.   spiral               vol_with_light
  11148.  
  11149.  
  11150. 7.1.2            Comments
  11151.  
  11152. Comments are text in the scene file included to make the scene file easier to
  11153. read or understand. They are ignored by the ray-tracer and are there for your
  11154. information. There are two types of comments in POV-Ray.
  11155.  
  11156. Two slashes are used for single line comments. Anything on a line after a
  11157. double slash (//) is ignored by the ray-tracer. For example:
  11158.  
  11159.   // This line is ignored
  11160.  
  11161.  
  11162. You can have scene file information on the line in front of the comment as
  11163. in:
  11164.  
  11165.   object { FooBar }  // this is an object
  11166.  
  11167.  
  11168. The other type of comment is used for multiple lines. It starts with "/*" and
  11169. ends with "*/". Everything in-between is ignored. For example:
  11170.  
  11171.   /* These lines
  11172.      are ignored
  11173.      by the
  11174.      ray-tracer */
  11175.  
  11176.  
  11177. This can be useful if you want to temporarily remove elements from a scene
  11178. file. /* ... */ comments can comment out lines containing other // comments
  11179. and thus can be used to temporarily or permanently comment out parts of a
  11180. scene. /* ... */ comments can be nested, the following is legal:
  11181.  
  11182.   /* This is a comment
  11183.   // This too
  11184.   /* This also */
  11185.   */
  11186.  
  11187.  
  11188. Use comments liberally and generously. Well used, they really improve the
  11189. readability of scene files.
  11190.  
  11191. 7.1.3            Float Expressions
  11192.  
  11193. Many parts of the POV-Ray language require you to specify one or more
  11194. floating point numbers. A floating point number is a number with a decimal
  11195. point. Floats may be specified using literals, identifiers or functions which
  11196. return float values. You may also create very complex float expressions from
  11197. combinations of any of these using various familiar operators.
  11198.  
  11199. Where POV-Ray needs an integer value it allows you to specify a float value
  11200. and it truncates it to an integer. When POV-Ray needs a logical or boolean
  11201. value it interprets any non-zero float as true and zero as false. Because
  11202. float comparisons are subject to rounding errors POV-Ray accepts values
  11203. extremely close to zero as being false when doing boolean functions.
  11204. Typically values whose absolute values are less than a preset value epsilon
  11205. are considered false for logical expressions. The value of epsilon is system
  11206. dependent but is generally about 1.0e-10. Two floats a and b are considered
  11207. to be equal if abs(a-b) < epsilon.
  11208.  
  11209. 7.1.3.1          Float Literals
  11210.  
  11211. Float literals are represented by an optional sign ("+" or "-") digits, an
  11212. optional decimal point and more digits. If the number is an integer you may
  11213. omit the decimal point and trailing zero. If it is all fractional you may
  11214. omit the leading zero. POV-Ray supports scientific notation for very large or
  11215. very small numbers. The following are all valid float literals:
  11216.  
  11217.   -2.0    -4    34    3.4e6    2e-5    .3    0.6
  11218.  
  11219.  
  11220. 7.1.3.2          Float Identifiers
  11221.  
  11222. Float identifiers may be declared to make scene files more readable and to
  11223. parameterize scenes so that changing a single declaration changes many
  11224. values. An identifier is declared as follows.
  11225.  
  11226.   #declare IDENTIFIER = EXPRESSION
  11227.  
  11228.  
  11229. Where IDENTIFIER is the name of the identifier up to 40 characters long and
  11230. EXPRESSION is any valid expression which evaluates to a float value. Here are
  11231. some examples.
  11232.  
  11233.   #declare Count = 0
  11234.   #declare Rows = 5.3
  11235.   #declare Cols = 6.15
  11236.   #declare Number = Rows*Cols
  11237.   #declare Count = Count+1
  11238.  
  11239.  
  11240. As the last example shows, you can re-declare a float identifier and may use
  11241. previously declared values in that re-declaration. There are several built-in
  11242. identifiers which POV-Ray declares for you. See "Built-in Identifiers" for
  11243. details.
  11244.  
  11245. 7.1.3.3          Float Operators
  11246.  
  11247. Arithmetic float expressions can be created from float literals, identifiers
  11248. or functions using the following operators in this order of precedence...
  11249.  
  11250.   ()             expressions in parentheses first
  11251.   +A   -A   !A   unary minus, unary plus and logical "not"
  11252.   A*B  A/B       multiplication and division
  11253.   A+B  A-B       addition and subtraction
  11254.  
  11255.  
  11256. Relational, logical and conditional expressions may also be created. However
  11257. there is a restriction that these types of expressions must be enclosed in
  11258. parentheses first. This restriction, which is not imposed by most computer
  11259. languages, is necessary because POV-Ray allows mixing of float and vector
  11260. expressions. Without the parentheses there is an ambiguity problem.
  11261. Parentheses are not required for the unary logical not operator "!" as shown
  11262. above. The operators and their precedence are shown here.
  11263.  
  11264. Relational expressions: The operands are arithmetic expressions and the
  11265. result is always boolean with 1 for true and 0 for false. All relational
  11266. operators have the same precedence.
  11267.  
  11268.   (A > B))A is greater than Br equal to Bbs(A-B)>=EPSILON)
  11269.  
  11270.  
  11271. Logical expressions: The operands are converted to boolean values of 0 for
  11272. false and 1 for true. The result is always boolean. All logical operators
  11273. have the same precedence. Note that these are not bit-wise operations, they
  11274. are logical.
  11275.  
  11276.   (A | B)true if either A or B or both are truelse otherwise
  11277.  
  11278.  
  11279. Conditional expressions: The operand C is boolean while operands A and B are
  11280. any expressions. The result is of the same type as A and B.
  11281.  
  11282.   (C ? A : B)if C then A else B
  11283.  
  11284.  
  11285. Assuming the various identifiers have been declared, the following are
  11286. examples of valid expressions...
  11287.  
  11288.   1+2+3       2*5         1/3         Row*3       Col*5
  11289.   (Offset-5)/2            This/That+Other*Thing
  11290.   ((This<That) & (Other>=Thing)?Foo:Bar)
  11291.  
  11292.  
  11293. Expressions are evaluated left to right with innermost parentheses evaluated
  11294. first, then unary +, - or !, then multiply or divide, then add or subtract,
  11295. then relational, then logical, then conditional.
  11296.  
  11297. 7.1.4            Vector Expressions
  11298.  
  11299. POV-Ray often requires you to specify a vector. A vector is a set of related
  11300. float values. Vectors may be specified using literals, identifiers or
  11301. functions which return vector values. You may also create very complex vector
  11302. expressions from combinations of any of these using various familiar
  11303. operators.
  11304.  
  11305. POV-Ray vectors may have from two to five components but the vast majority of
  11306. vectors have three components. Unless specified otherwise, you should assume
  11307. that the word vector means a three component vector. POV-Ray operates in a 3D
  11308. x, y, z coordinate system and you will use three component vectors to specify
  11309. x, y and z values. In some places POV-Ray needs only two coordinates. These
  11310. are often specified by a 2D vector called an UV vector. Fractal objects use
  11311. 4D vectors. Color expressions use 5D vectors but allow you to specify 3, 4 or
  11312. 5 components and use default values for the unspecified components. Unless
  11313. otherwise noted, all 2, 4 or 5 component vectors work just like 3D vectors
  11314. but they have a different number of components.
  11315.  
  11316. 7.1.4.1          Vector Literals
  11317.  
  11318. Vectors consist of two to five float expressions that are bracketed by angle
  11319. brackets < and >. The terms are separated by commas. For example here is a
  11320. typical three component vector:
  11321.  
  11322.   < 1.0, 3.2, -5.4578 >
  11323.  
  11324.  
  11325. The commas between components are necessary to keep the program from thinking
  11326. that the 2nd term is the single float expression 3.2-5.4578 and that there is
  11327. no 3rd term. If you see an error message such as Float expected but '>' found
  11328. instead you probably have missed a comma.
  11329.  
  11330. Sometimes POV-Ray requires you to specify floats and vectors side-by-side.
  11331. The rules for vector expressions allow for mixing of vectors with vectors or
  11332. vectors with floats so commas are required separators whenever an ambiguity
  11333. might arise. For example < 1,2,3>-4 evaluates as a mixed float and vector
  11334. expression where 4 is subtracted from each component resulting in <
  11335. -3,-2,-1>. However the comma in <1,2,3>,-4 means this is a vector followed by
  11336. a float.
  11337.  
  11338. Each component may be a full float expression. For example <
  11339. This+3,That/3,5*Other_Thing> is a valid vector.
  11340.  
  11341. 7.1.4.2          Vector Identifiers
  11342.  
  11343. Vector identifiers may be declared to make scene files more readable and to
  11344. parameterize scenes so that changing a single declaration changes many
  11345. values. An identifier is declared as follows...
  11346.  
  11347.   #declare IDENTIFIER = EXPRESSION
  11348.  
  11349.  
  11350. Where IDENTIFIER is the name of the identifier up to 40 characters long and
  11351. EXPRESSION is any valid expression which evaluates to a vector value. Here
  11352. are some examples...
  11353.  
  11354.   #declare Here = <1,2,3>
  11355.   #declare There = <3,4,5>
  11356.   #declare Jump = <Foo*2,Bar-1,Bob/3>
  11357.   #declare Route = There-Here
  11358.   #declare Jump = Jump+<1,2,3>
  11359.  
  11360.  
  11361. Note that you invoke a vector identifier by using its name without any angle
  11362. brackets. As the last example shows, you can re-declare a vector identifier
  11363. and may use previously declared values in that re-declaration. There are
  11364. several built-in identifiers which POV-Ray declares for you. See section
  11365. "Built-in Identifiers" for details.
  11366.  
  11367. 7.1.4.3          Vector Operators
  11368.  
  11369. Vector literals, identifiers and functions may also be combined in
  11370. expressions the same as float values. Operations are performed on a
  11371. component-by-component basis. For example <1,2,3> + <4,5,6> evaluates the
  11372. same as < 1+4,2+5,3+6> or <5,7,9>. Other operations are done on a similar
  11373. component-by-component basis. For example (< 1,2,3> = <3,2,1>) evaluates to <
  11374. 0,1,0> because the middle components are equal but the others are not.
  11375. Admittedly this isn't very useful but its consistent with other vector
  11376. operations.
  11377.  
  11378. Conditional expressions such as (C ? A : B) require that C is a float
  11379. expression but A and B may be vector expressions. The result is that the
  11380. entire conditional evaluates as a valid vector. For example if Foo and Bar
  11381. are floats then
  11382.  
  11383.   Foo < Bar ? <1,2,3> : <5,6,7>
  11384. evaluates as the vector <1,2,3> if Foo is less than Bar and evaluates as
  11385. <5,6,7> otherwise.
  11386.  
  11387. You may use the dot operator to extract a single component from a vector.
  11388. Suppose the identifier Spot was previously defined as a vector. Then Spot.x
  11389. is a float value that is the first component of this x, y, z vector.
  11390. Similarly Spot.y and Spot.z reference the 2nd and 3rd components. If Spot was
  11391. a two component UV vector you could use Spot.u and Spot.v to extract the
  11392. first and second component. For a 4D vector use .x, .y, .z and .t to extract
  11393. each float component. The dot operator is also used in color expressions
  11394. which are covered later.
  11395.  
  11396. 7.1.4.4          Operator Promotion
  11397.  
  11398. You may use a lone float expression to define a vector whose components are
  11399. all the same. POV-Ray knows when it needs a vector of a particular type and
  11400. will promote a float into a vector if need be. For example the POV-Ray scale
  11401. statement requires a three component vector. If you specify scale 5 then
  11402. POV-Ray interprets this as scale <5,5,5> which means you want to scale by 5
  11403. in every direction.
  11404.  
  11405. Versions of POV-Ray prior to 3.0 only allowed such use of a float as a vector
  11406. in various limited places such as scale and turbulence. However you may now
  11407. use this trick anywhere. For example...
  11408.  
  11409.   box{0,1}    // Same as box{<0,0,0>,<1,1,1>}
  11410.   sphere{0,1} // Same as sphere{<0,0,0>,1}
  11411.  
  11412.  
  11413. When promoting a float into a vector of 2, 3, 4 or 5 components, all
  11414. components are set to the float value, however when promoting a vector of a
  11415. lower number of components into a higher order vector, all remaining
  11416. components are set to zero. For example if POV-Ray expects a 4D vector and
  11417. you specify 9 the result is <9,9,9,9> but if you specify <7,6> the result is
  11418. < 7,6,0,0>.
  11419.  
  11420. 7.1.5            Specifying Colors
  11421.  
  11422. POV-Ray often requires you to specify a color. Colors consist of five values
  11423. or color components. The first three are called red, green and blue. They
  11424. specify the intensity of the primary colors red, green and blue using an
  11425. additive color system like the one used by the red, green and blue color
  11426. phosphors on a color monitor.
  11427.  
  11428. The 4th component, called filter, specifies the amount of filtered
  11429. transparency of a substance. Some real-world examples of filtered
  11430. transparency are stained glass windows or tinted cellophane. The light
  11431. passing through such objects is tinted by the appropriate color as the
  11432. material selectively absorbs some frequencies of light while allowing others
  11433. to pass through. The color of the object is subtracted from the light passing
  11434. through so this is called subtractive transparency.
  11435.  
  11436. The 5th component, called transmit, specifies the amount of non-filtered
  11437. light that is transmitted through a surface. Some real-world examples of
  11438. non-filtered transparency are thin see-through cloth, fine mesh netting and
  11439. dust on a surface. In these examples, all frequencies of light are allowed to
  11440. pass through tiny holes in the surface. Although the amount of light passing
  11441. through is diminished, the color of the light passing through is unchanged.
  11442. The color of the object is added to the light passing through so this is
  11443. called additive transparency.
  11444.  
  11445. Note that early versions of POV-Ray used the keyword alpha to specify
  11446. filtered transparency. However that word is often used to describe
  11447. non-filtered transparency. For this reason alpha is no longer used.
  11448.  
  11449. Each of the five components of a color are float values which are normally in
  11450. the range between 0.0 and 1.0. However any values, even negatives may be
  11451. used.
  11452.  
  11453. Colors may be specified using vectors, keywords with floats or identifiers.
  11454. You may also create very complex color expressions from combinations of any
  11455. of these using various familiar operators. The syntax for specifying a color
  11456. has evolved since POV-Ray was first released. We have maintained the original
  11457. keyword-based syntax and added a short-cut vector notation. Either the old or
  11458. new syntax is acceptable however the vector syntax is easier to use when
  11459. creating color expressions.
  11460.  
  11461. 7.1.5.1          Color Vectors
  11462.  
  11463. The syntax for a color vector is any of the following...
  11464.  
  11465.   color rgb VECTOR3
  11466.   color rgbf VECTOR4
  11467.   color rgbt VECTOR4
  11468.   color rgbft VECTOR5
  11469.  
  11470.  
  11471. where VECTOR3, VECTOR4 or VECTOR5 are any valid vector expressions of 3, 4 or
  11472. 5 components. For example
  11473.  
  11474.   color rgb <1.0, 0.5, 0.2>
  11475.  
  11476.  
  11477. This specifies a color whose red component is 1.0 or 100% of full intensity.
  11478. The green component is 0.5 or 50% of full intensity and the blue component is
  11479. 0.2 or 20% of full intensity. Although the filter and transmit components are
  11480. not explicitly specified, they exist and are set to their default values of 0
  11481. or no transparency.
  11482.  
  11483. The rgbf keyword requires a four component vector. The 4th component is the
  11484. filter component and the transmit component defaults to zero. Similarly the
  11485. rgbt keyword requires four components where the 4th value is moved to the 5th
  11486. component which is transmit and then the filter component is set to zero.
  11487.  
  11488. The rgbft keyword allows you to specify all five components. Internally in
  11489. expressions all five are always used.
  11490.  
  11491. Under most circumstances the keyword color is optional and may be omitted. We
  11492. also support the British or Canadian spelling colour. Under some
  11493. circumstances, if the vector expression is a 5 component expression or there
  11494. is a color identifier in the expression then the rgbtf keyword is optional.
  11495.  
  11496. 7.1.5.2          Color Keywords
  11497.  
  11498. The older keyword method of specifying a color is still useful and many users
  11499. prefer it. Like a color vector, you begin with the optional keyword color.
  11500. This is followed by any of five additional keywords red, green, blue, filter
  11501. or transmit. Each of these component keywords is followed by a float
  11502. expression. For example
  11503.  
  11504.   color red 1.0 green 0.5
  11505.  
  11506.  
  11507. This specifies a color whose red component is 1.0 or 100% of full intensity
  11508. and the green component is 0.5 or 50% of full intensity. Although the blue,
  11509. filter and transmit components are not explicitly specified, they exist and
  11510. are set to their default values of 0. The component keywords may be given in
  11511. any order and if any component is unspecified its value defaults to zero.
  11512.  
  11513. 7.1.5.3          Color Identifiers
  11514.  
  11515. Color identifiers may be declared to make scene files more readable and to
  11516. parameterize scenes so that changing a single declaration changes many
  11517. values. A color identifier is declared as either of the following...
  11518.  
  11519.   #declare IDENTIFIER = COLOR_VECTOR
  11520.   #declare IDENTIFIER = COLOR_KEYWORDS...
  11521.  
  11522.  
  11523. Where IDENTIFIER is the name of the identifier up to 40 characters long and
  11524. COLOR_VECTOR or COLOR_KEYWORDS are any valid color specifications as
  11525. described in the two previous sections of this document. Here are some
  11526. examples...
  11527.  
  11528.   #declare White = rgb <1,1,1>
  11529.   #declare Cyan = color blue 1.0  green 1.0
  11530.   #declare Weird = rgb <Foo*2,Bar-1,Bob/3>
  11531.   #declare LightGray = White*0.8
  11532.   #declare LightCyan = Cyan red 0.6
  11533.  
  11534.  
  11535. As the LightGray example shows you do not need any color keywords when
  11536. creating color expressions based on previously declared colors. The last
  11537. example shows you may use a color identifier with the keyword style syntax.
  11538. Make sure that the identifier comes first before any other component
  11539. keywords.
  11540.  
  11541. Like floats and vectors, you may re-define colors throughout a scene but the
  11542. need to do so is rare.
  11543.  
  11544. 7.1.5.4          Color Operators
  11545.  
  11546. Color vectors may be combined in expressions the same as float or vector
  11547. values. Operations are performed on a component-by-component basis. For
  11548. example rgb <1.0, 0.5 0.2> * 0.9 evaluates the same as rgb <1.0, 0.5 0.2> *
  11549. <0.9, 0.9, 0.9> or rgb <0.9, 0.45,  0.18>. Other operations are done on a
  11550. similar component-by-component basis.
  11551.  
  11552. You may use the dot operator to extract a single component from a color.
  11553. Suppose the identifier Shade was previously defined as a color. Then
  11554. Shade.red is the float value of the red component of Shade. Similarly
  11555. Shade.green, Shade.blue, Shade.filter and Shade.transmit extract the float
  11556. value of the other color components.
  11557.  
  11558. 7.1.5.5          Common Color Pitfalls
  11559.  
  11560. The variety and complexity of color specification methods can lead to some
  11561. common mistakes. Here are some things to consider when specifying a color.
  11562.  
  11563. When using filter transparency, the colors which come through are multiplied
  11564. by the primary color components. For example if gray light such as rgb
  11565. <0.9,0.9,0.9> passes through a filter such as rgbf <1.0,0.5,0.0,1.0> the
  11566. result is rgb <0.9,0.45,0.0> with the red let through 100%, the green cut in
  11567. half from 0.9 to 0.45 and the blue totally blocked. Often users mistakenly
  11568. specify a clear object by
  11569.  
  11570.   color filter 1.0
  11571.  
  11572.  
  11573. but this has implied red, green and blue values of zero. You've just
  11574. specified a totally black filter so no light passes through. The correct way
  11575. is either
  11576.  
  11577.   color red 1.0   green 1.0   blue 1.0   filter 1.0
  11578.  
  11579.  
  11580. or
  11581.  
  11582.   color transmit 1.0
  11583.  
  11584.  
  11585. In the 2nd example it doesn't matter what the rgb values are. All of the
  11586. light passes through untouched.
  11587.  
  11588. Another pitfall is the use of color identifiers and expressions with color
  11589. keywords. For example...
  11590.  
  11591.   color My_Color red 0.5
  11592.  
  11593.  
  11594. this substitutes whatever was the red component of My_Color with a red
  11595. component of 0.5 however...
  11596.  
  11597.   color My_Color + red 0.5
  11598.  
  11599.  
  11600. adds 0.5 to the red component of My_Color and even less obvious...
  11601.  
  11602.   color My_Color * red 0.5
  11603.  
  11604.  
  11605. that cuts the red component in half as you would expect but it also
  11606. multiplies the green, blue, filter and transmit components by zero! The part
  11607. of the expression after the multiply operator evaluates to rgbft
  11608. <0.5,0,0,0,0> as a full 5 component color.
  11609.  
  11610. The following example results in no change to My_Color.
  11611.  
  11612.   color red 0.5 My_Color
  11613.  
  11614.  
  11615. This is because the identifier fully overwrites the previous value. When
  11616. using identifiers with color keywords, the identifier should be first.
  11617.  
  11618. One final issue, some POV-Ray syntax allows full color specifications but
  11619. only uses the rgb part. In these cases it is legal to use a float where a
  11620. color is needed. For example:
  11621.  
  11622.   finish { ambient 1 }
  11623.  
  11624.  
  11625. The ambient keyword expects a color so the value 1 is promoted to <1,1,1,1,1>
  11626. which is no problem. However
  11627.  
  11628.   pigment { color 0.4 }
  11629.  
  11630.  
  11631. is legal but it may or may not be what you intended. The 0.4 is promoted to
  11632. <0.4,0.4,0.4,0.4,0.> with the filter and transmit set to 0.4 as well. It is
  11633. more likely you wanted...
  11634.  
  11635.   pigment { color rgb 0.4 }
  11636.  
  11637.  
  11638. in which case a 3 component vector is expected. Therefore the 0.4 is promoted
  11639. to <0.4,0.4,0.4,0.0,0.0> with default zero for filter and transmit.
  11640.  
  11641. 7.1.6            Strings
  11642.  
  11643. The POV-Ray language requires you to specify a string of characters to be
  11644. used as a file name, text for messages or text for a text object. Strings may
  11645. be specified using literals, identifiers or functions which return string
  11646. values. Although you cannot build string expressions from symbolic operators
  11647. such as are used with floats, vectors or colors, you may perform various
  11648. string operations using string functions. Some applications of strings in
  11649. POV-Ray allow for non-printing formatting characters such as newline or
  11650. form-feed.
  11651.  
  11652. 7.1.6.1          String Literals
  11653.  
  11654. String literals begin with a double quote mark '"' which is followed by up to
  11655. 256 printable ASCII characters and are terminated by another double quote
  11656. mark. The following are all valid string literals:
  11657.  
  11658.   "Here"   "There"    "myfile.gif"    "textures.inc"
  11659.  
  11660.  
  11661. Note if you need to specify a quote mark in a string literal you must preceed
  11662. it with a backslash. For example
  11663.  
  11664.   "Joe said \"Hello\" as he walked in."
  11665.  
  11666.  
  11667. is converted to
  11668.  
  11669.   Joe said "Hello" as he walked in.
  11670.  
  11671.  
  11672. If you need to specify a backslash, most of the time you need do nothing
  11673. special. However if the string ends in a backslash, you will have to specify
  11674. two. For example:
  11675.  
  11676.   "This is a backslash  and so is this"
  11677.  
  11678.  
  11679. Is converted to:
  11680.  
  11681.   This is a backslash  and so is this\
  11682.  
  11683.  
  11684. The
  11685.  
  11686. regardless usage however other formating codes such as \n for new line are
  11687. supported in user message streams. See "Text Formatting" for details.
  11688.  
  11689. 7.1.6.2          String Identifiers
  11690.  
  11691. String identifiers may be declared to make scene files more readable and to
  11692. parameterize scenes so that changing a single declaration changes many
  11693. values. An identifier is declared as follows...
  11694.  
  11695.   #declare IDENTIFIER = STRING
  11696.  
  11697.  
  11698. Where IDENTIFIER is the name of the identifier up to 40 characters long and
  11699. STRING is a string literal, string identifier or function which returns a
  11700. string value. Here are some examples...
  11701.  
  11702.   #declare Font_Name = "ariel.ttf"
  11703.   #declare Inc_File = "myfile.inc"
  11704.   #declare Name = "John"
  11705.   #declare Name = concat(Name," Doe")
  11706.  
  11707.  
  11708. As the last example shows, you can re-declare a string identifier and may use
  11709. previously declared values in that re-declaration.
  11710.  
  11711. 7.1.7            Built-in Identifiers
  11712.  
  11713. There are several built-in float and vector identifiers. You can use them to
  11714. specify values or to create expressions but you cannot re-declare them to
  11715. change their values.
  11716.  
  11717. 7.1.7.1          Constant Built-in Identifiers
  11718.  
  11719. Most built-in identifiers never change value. They are defined as though the
  11720. following lines were at the start of every scene.
  11721.  
  11722.   #declare pi = 3.1415926535897932384626
  11723.   #declare true = 1
  11724.   #declare yes = 1
  11725.   #declare on = 1
  11726.   #declare false = 0
  11727.   #declare no = 0
  11728.   #declare off = 0
  11729.   #declare u = <1,0>
  11730.   #declare v = <0,1>
  11731.   #declare x = <1,0,0>
  11732.   #declare y = <0,1,0>
  11733.   #declare z = <0,0,1>
  11734.   #declare t = <0,0,0,1>
  11735.  
  11736.  
  11737. The built-in float identifier pi is obviously useful in math expressions
  11738. involving circles.
  11739.  
  11740. The built-in float identifiers on,off, yes, no, true and false are designed
  11741. for use as boolean constants.
  11742.  
  11743. The built-in vector identifiers x, y and z provide much greater readability
  11744. for your scene files when used in vector expressions. For example....
  11745.  
  11746.   plane { y, 1}        // The normal vector is obviously "y".
  11747.   plane { <0,1,0>, 1}  // This is harder to read.
  11748.  
  11749.   translate 5*x        // Move 5 units in the "x" direction.
  11750.   translate <5,0,0>    // This is less obvious.
  11751.  
  11752.  
  11753. An expression like 5*x evaluates to 5 <1,0,0> or <5,0,0>.
  11754.  
  11755. Similarly u and v may be used in 2D vectors. When using 4D vectors you should
  11756. use x, y, z, and t and POV-Ray will promote x, y and z to 4D when used where
  11757. 4D is required.
  11758.  
  11759. 7.1.7.2          Built-in Identifier 'clock'
  11760.  
  11761. The built-in float identifier clock is used to control animations in POV-Ray.
  11762. Unlike some animation packages, the action in POV-Ray animated scenes does
  11763. not depend upon the integer frame numbers. Rather you should design your
  11764. scenes based upon the float identifier clock. For non-animated scenes its
  11765. default value is 0 but you can set it to any float value using the INI file
  11766. option Clock=n.n or the command-line switch +Kn.n to pass a single float
  11767. value your scene file.
  11768.  
  11769. Other INI options and switches may be used to animate scenes by automatically
  11770. looping through the rendering of frames using various values for clock. By
  11771. default, the clock value is 0 for the initial frame and 1 for the final
  11772. frame. All other frames are interpolated between these values. For example if
  11773. your object is supposed to rotate one full turn over the course of the
  11774. animation you could specify rotate 360*clock*y. Then as clock runs from 0 to
  11775. 1, the object rotates about the y-axis from 0 to 360 degrees.
  11776.  
  11777. Although the value of clock will change from frame-to-frame, it will never
  11778. change throughout the parsing of a scene.
  11779.  
  11780.  
  11781. 7.1.7.3          Built-in Identifier 'version'
  11782.  
  11783. The built-in float identifier version contains the current setting of the
  11784. version compatibility option. Although this value defaults to 3 which is the
  11785. current POV-Ray version number, the initial value of version may be set by
  11786. the INI file option Version=n.n or by the +MVn.n command-line switch. This
  11787. tells POV-Ray to parse the scene file using syntax from an earlier version of
  11788. POV-Ray.
  11789.  
  11790. The INI option or switch only affects the initial setting. Unlike other
  11791. built-in identifiers, you may change the value of version throughout a scene
  11792. file. You do not use #declare to change it though. The #version language
  11793. directive is used to change modes. Such changes may occur several times
  11794. within scene files.
  11795.  
  11796. Together with the built-in version identifier the #version directive allows
  11797. you to save and restore the previous values of this compatibility setting.
  11798. For example suppose mystuff.inc is in version 1 format. At the top of the
  11799. file you could put:
  11800.  
  11801.   #declare Temp_Vers = version    // Save previous value
  11802.   #version 1.0                    // Change to 1.0 mode
  11803.  
  11804.   ... // Version 1.0 stuff goes here...
  11805.  
  11806.   #version Temp_Vers              // Restore previous version
  11807.  
  11808.  
  11809. 7.1.8            Functions
  11810.  
  11811. POV-Ray defines a variety of built-in functions for manipulating floats,
  11812. vectors and strings. The functions are listed grouped according to their
  11813. usage and not by the type of value they return. For example vdot computes the
  11814. dot product of two vectors and is listed as a vector function even though it
  11815. returns a single float value.
  11816.  
  11817. Function calls consist of a keyword which specifies the name of the function
  11818. followed by a parameter list enclosed in parentheses. Parameters are
  11819. separated by commas. For example:
  11820.  
  11821.   keyword(param1,param2)
  11822.  
  11823.  
  11824. Functions evaluate to values that are floats, vectors or strings and may be
  11825. used in expressions or statements anywhere that literals or identifiers of
  11826. that type may be used.
  11827.  
  11828. 7.1.8.1          Float Functions
  11829.  
  11830. The following are the functions which take one or more float parameters and
  11831. return float values. Assume that A and B are any valid expression that
  11832. evaluates to a float. See section "Vector Functions" and section "String
  11833. Functions" for other functions which return float values but whose primary
  11834. purpose is more closely related to vectors and strings.
  11835.  
  11836. abs(A): Absolute value of A. If A is negative, returns -A otherwise returns
  11837. A.
  11838.  
  11839. acos(A): Arc-cosine of A. Returns the angle, measured in radians, whose
  11840. cosine is A.
  11841.  
  11842. asin(A): Arc-sine of A. Returns the angle, measured in radians, whose sine is
  11843. A.
  11844.  
  11845. atan2(A,B): Arc-tangent of (A/B). Returns the angle, measured in radians,
  11846. whose tangent is (A/B). Returns appropriate value even if B is zero. Use
  11847. atan2(A,1) to compute usual atan(A) function.
  11848.  
  11849. ceil(A): Ceiling of A. Returns the smallest integer greater than A. Rounds up
  11850. to the next higher integer.
  11851.  
  11852. cos(A): Cosine of A. Returns the cosine of the angle A, where A is measured
  11853. in radians.
  11854.  
  11855. degrees(A): Convert radians to degrees. Returns the angle measured in degrees
  11856. whose value in radians is A. Formula is degrees=A/pi*180.0.
  11857.  
  11858. div(A,B): Integer division. The integer part of (A/B).
  11859.  
  11860. exp(A): Exponential of A. Returns the value of e raised to the power A where
  11861. e is the base of the natural logarithm, i.e. the non-repeating value
  11862. approximately equal to 2.71828182846.
  11863.  
  11864. floor(A): Floor of A. Returns the largest integer less than A. Rounds down to
  11865. the next lower integer.
  11866.  
  11867. int(A): Integer part of A. Returns the truncated integer part of A. Rounds
  11868. towards zero.
  11869.  
  11870. log(A): Natural logarithm of A. Returns the natural logarithm base e of the
  11871. value A.
  11872.  
  11873. max(A,B): Maximum of A and B. Returns A if A larger than B. Otherwise returns
  11874. B.
  11875.  
  11876. min(A,B): Minimum of A and B. Returns A if A smaller than B. Otherwise
  11877. returns B.
  11878.  
  11879. mod(A,B): Value of A modulo B. Returns the remainder after the integer
  11880. division of A/B. Formula is mod=((A/B)-int(A/B))*B.
  11881.  
  11882. pow(A,B): Exponentiation. Returns the value of A raised to the power B.
  11883.  
  11884. radians(A): Convert degrees to radians. Returns the angle measured in radians
  11885. whose value in degrees is A. Formula is radians=A*pi/180.0.
  11886.  
  11887. rand(A): Returns the next pseudo-random number from the stream specified by
  11888. the positive integer A. You must call seed() to initialize a random stream
  11889. before calling rand(). The numbers are uniformly distributed, and have values
  11890. between 0.0 and 1.0, inclusively. The numbers generated by separate streams
  11891. are independent random variables.
  11892.  
  11893. seed(A): Initializes a new pseudo-random stream with the initial seed value
  11894. A. The number corresponding to this random stream is returned. Any number of
  11895. pseudo-random streams may be used as shown in the example below:
  11896.  
  11897.   #declare R1 = seed(0)
  11898.   #declare R2 = seed(12345)
  11899.  
  11900.   #sphere { <rand(R1), rand(R1), rand(R1)>, rand(R2) }
  11901.  
  11902.  
  11903. Multiple random generators are very useful in situations where you use rand()
  11904. to place a group of objects, and then decide to use rand() in another
  11905. location earlier in the file to set some colors or place another group of
  11906. objects. Without separate rand() streams, all of your objects would move when
  11907. you added more calls to rand(). This is very annoying.
  11908.  
  11909. sin(A): Sine of A. Returns the sine of the angle A, where A is measured in
  11910. radians.
  11911.  
  11912. sqrt(A): Square root of A. Returns the value whose square is A.
  11913.  
  11914. tan(A): Tangent of A. Returns the tangent of the angle A, where A is measured
  11915. in radians.
  11916.  
  11917. 7.1.8.2          Vector Functions
  11918.  
  11919. The following are the functions which take one or more vector and float
  11920. parameters and return vector or float values. All of these functions support
  11921. only three component vectors. Assume that A and B are any valid expression
  11922. that evaluates to a three component vector and that F is any valid expression
  11923. that evaluates to a float.
  11924.  
  11925. vaxis_rotate(A,B,F): Rotate A about B by F. Given the x,y,z coordinates of a
  11926. point in space designated by the vector A, rotate that point about an
  11927. arbitrary axis defined by the vector B. Rotate it through an angle specified
  11928. in degrees by the float value F. The result is a vector containing the new
  11929. x,y,z coordinates of the point.
  11930.  
  11931. vcross(A,B): Cross product of A and B. Returns a vector that is the vector
  11932. cross product of the two vectors. The resulting vector is perpendicular to
  11933. the two original vectors and its length is proportional to the angle between
  11934. them. See the animated demo scene VECT2.POV for an illustration.
  11935.  
  11936. vdot(A,B): Dot product of A and B. Returns a float value that is the dot
  11937. product (sometimes called scaler product of A with B. Formula is vdot=A.x*B.x
  11938. + A.y*B.y + A.z*B.z. See the animated demo scene VECT2.POV for an
  11939. illustration.
  11940.  
  11941. vlength(A): Length of A. Returns a float value that is the length of vector
  11942. A. Can be used to compute the distance between two points. Dist=vlength(B-A).
  11943. Formula is vlength=sqrt(vdot(A,A)).
  11944.  
  11945. vnormalize(A): Normalize vector A. Returns a unit length vector that is the
  11946. same direction as A. Formula is vnormalize=A/vlength(A).
  11947.  
  11948. vrotate(A,B): Rotate A about origin by B. Given the x,y,z coordinates of a
  11949. point in space designated by the vector A, rotate that point about the origin
  11950. by an amount specified by the vector B. Rotate it about the x-axis by an
  11951. angle specified in degrees by the float value B.x. Similarly B.y and B.z
  11952. specify the amount to rotate in degrees about the y-axis and z-axis. The
  11953. result is a vector containing the new x,y,z coordinates of the point.
  11954.  
  11955. 7.1.8.3          String Functions
  11956.  
  11957. The following are the functions which take one or more string and float
  11958. parameters and return string or float values. Assume that S1 and S2 are any
  11959. valid strings and that A, L and P are any valid expressions that evaluate to
  11960. floats.
  11961.  
  11962. asc(S1): ASCII value of S1. Returns an integer value in the range 0 to 255
  11963. that is the ASCII value of the first character of S1. For example asc("ABC")
  11964. is 65 because that is the value of the character "A".
  11965.  
  11966. chr(A): Character whose ASCII value is A. Returns a single character string.
  11967. The ASCII value of the character is specified by an integer A which must be
  11968. in the range 0 to 255. For example chr(70) is the string "F". When rendering
  11969. text objects you should be aware that the characters rendered for values of A
  11970. > 127 are dependent on the (TTF) font being used. Many (TTF) fonts use the
  11971. Latin-1 (ISO 8859-1) character set, but not all do.
  11972.  
  11973. concat(S1,S2,[S3...]): Concatenate strings S1 and S2. Returns a string that
  11974. is the concatenation of all parameter strings. Must have at least 2
  11975. parameters but may have more. For example:
  11976.  
  11977.   concat("Value is ", str(A,3,1), " inches")
  11978.  
  11979.  
  11980. If the float value A was 12.34 the result is "Value is 12.3 inches" which is
  11981. a string.
  11982.  
  11983. file_exists(S1): Search for file specified by S1. Attempts to open the file
  11984. whose name is specified by the string S1. The current directory and all
  11985. directories specified in any Library_Path INI options or +L command line
  11986. switches are searched. File is immediately closed. Returns a boolean value 1
  11987. on success and 0 on failure.
  11988.  
  11989. str(A,L,P): Convert float A to a formatted string. Returns a formatted string
  11990. representation of float value A. The float parameter L specifies the minimum
  11991. length of the string and the type of left padding used if the string's
  11992. representation is shorter than the minimum. If L is positive then the padding
  11993. is with blanks. If L is negative then the padding is with zeros. The overall
  11994. minimum length of the formatted string is abs(L). If the string needs to be
  11995. longer, it will be made as long as necessary to represent the value.
  11996.  
  11997. The float parameter P specifies the number of digits after the decimal point.
  11998. If P is negative then a compiler-specific default precision is use. Here are
  11999. some examples:
  12000.  
  12001.   str(123.456,0,3)   "123.456"
  12002.   str(123.456,4,3)   "123.456"
  12003.   str(123.456,9,3)   "  123.456"
  12004.   str(123.456,-9,3)  "00123.456"
  12005.   str(123.456,0,2)   "123.46"
  12006.   str(123.456,0,0)   "123"
  12007.   str(123.456,5,0)   "  123"
  12008.   str(123.000,7,2)   " 123.00"
  12009.   str(123.456,0,-1)  "123.456000" (platform specific)
  12010.  
  12011.  
  12012. strcmp(S1,S2): Compare string S1 to S2. Returns a float value zero if the
  12013. strings are equal, a positive number if S1 comes after S2 in the ASCII
  12014. collating sequence, else a negative number.
  12015.  
  12016. strlen(S1): Length of S1. Returns an integer value that is the number of
  12017. characters in the string S1.
  12018.  
  12019. strlwr(S1): Lower case of S1. Returns a new string in which all upper case
  12020. letters in the string S1 are converted to lower case. The original string is
  12021. not affected. For example strlwr("Hello There!") results in "hello there!".
  12022.  
  12023. substr(S1,P,L): Sub-string from S1. Returns a string that is a subset of the
  12024. characters in parameter S1 starting at the position specified by the integer
  12025. value P for a length specified by the integer value L. For example
  12026. substr("ABCDEFGHI",4,2) evaluates to the string "EF". If P+L>strlen(S1) an
  12027. error occurs.
  12028.  
  12029. strupr(S1): Upper case of S1. Returns a new string in which all lower case
  12030. letters in the string S1 are converted to upper case. The original string is
  12031. not affected. For example strupr("Hello There!") results in "HELLO THERE!".
  12032.  
  12033. val(S1): Convert string S1 to float. Returns a float value that is
  12034. represented by the text in S1. For example val("123.45") is 123.45 as a
  12035. float.
  12036.  
  12037. 7.2              Language Directives
  12038.  
  12039. The POV Scene Language contains several statements called language
  12040. directives which tell the file parser how to do its job. These directives can
  12041. appear in almost any place in the scene file - even in the middle of some
  12042. other statements. They are used to include other text files in the stream of
  12043. commands, to declare identifiers, to define conditional or looped parsing and
  12044. to control other important aspects of scene file processing.
  12045.  
  12046. Each directive begins with the hash character # (often called a number sign
  12047. or pound sign). It is followed by a keyword and optionally other parameters.
  12048.  
  12049. In versions of POV-Ray prior to 3.0, the use of this # character was
  12050. optional. Language directives could only be used between objects, camera or
  12051. light_source statements and could not appear within those statements. The
  12052. exception was the #include which could appear anywhere. Now that all language
  12053. directives can be used almost anywhere, the # character is mandatory.
  12054.  
  12055. The following keywords introduce language directives.
  12056.  
  12057.  
  12058. #break              #default            #statistics
  12059. #case               #else               #switch
  12060. #debug              #end                #version
  12061. #declare            #render             #warning
  12062.  
  12063.  
  12064. Earlier versions of POV-Ray considered the keyword
  12065. #max_intersections and the keyword #max_trace_level to
  12066. be language directives but they have been moved to the
  12067. global_settings statement. Their use as a directive still works
  12068. but it generates a warning and may be discontinued in the future.
  12069.  
  12070.  
  12071. 7.2.1            Include Files
  12072.  
  12073. The language allows include files to be specified by placing the line
  12074.  
  12075.   #include "filename.inc"
  12076.  
  12077.  
  12078. at any point in the input file. The filename may be specified by any valid
  12079. string expression but it usually is a literal string enclosed in double
  12080. quotes. It may be up to 40 characters long (or your computer's limit),
  12081. including the two double-quote characters.
  12082.  
  12083. The include file is read in as if it were inserted at that point in the file.
  12084. Using include is the same as actually cutting and pasting the entire contents
  12085. of this file into your scene.
  12086.  
  12087. Include files may be nested. You may have at most 10 nested include files.
  12088. There is no limit on un-nested include files.
  12089.  
  12090. Generally, include files have data for scenes but are not scenes in
  12091. themselves. By convention scene files end in .pov and include files end with
  12092. .inc.
  12093.  
  12094. It is legal to specify drive and directory information in the file
  12095. specification however it is discouraged because it makes scene files less
  12096. portable between various platforms.
  12097.  
  12098. It is typical to put standard include files in a special sub-directory.
  12099. POV-Ray can only read files in the current directory or one referenced by the
  12100. Library_Path option (See section "Library Paths").
  12101.  
  12102. 7.2.2            Declare
  12103.  
  12104. Identifiers may be declared and later referenced to make scene files more
  12105. readable and to parametrize scenes so that changing a single declaration
  12106. changes many values. There are several built-in identifiers which POV-Ray
  12107. declares for you. See section "Built-in Identifiers"  for details.
  12108.  
  12109. 7.2.2.1          Declaring identifiers
  12110.  
  12111. An identifier is declared as follows.
  12112.  
  12113.   #declare IDENTIFIER = ITEM
  12114.  
  12115.  
  12116. Where IDENTIFIER is the name of the identifier up to 40 characters long and
  12117. ITEM is any of the following
  12118.  
  12119.   float, vector, color or string expressions
  12120.   objects (all kinds)
  12121.   texture, pigment, normal, finish or halo
  12122.   color_map, pigment_map, slope_map, normal_map
  12123.   camera, light_source
  12124.   atmosphere
  12125.   fog
  12126.   rainbow
  12127.   sky_sphere
  12128.   transform
  12129.  
  12130.  
  12131. Here are some examples.
  12132.  
  12133.   #declare Rows = 5
  12134.   #declare Count = Count+1
  12135.   #declare Here = <1,2,3>
  12136.   #declare White = rgb <1,1,1>
  12137.   #declare Cyan = color blue 1.0  green 1.0
  12138.   #declare Font_Name = "ariel.ttf"
  12139.   #declare Ring = torus {5,1}
  12140.   #declare Checks = pigment { checker White, Cyan }
  12141.  
  12142.   object{ Rod scale y*5 }         // not "cylinder { Rod }"
  12143.   object {
  12144.     Ring
  12145.     pigment { Checks scale 0.5 }
  12146.     transform Skew
  12147.   }
  12148.  
  12149.  
  12150. Declarations, like most language directives, can appear anywhere in the file
  12151. - even within other statements. For example:
  12152.  
  12153.   #declare Here=<1,2,3>
  12154.   #declare Count=0                   // initialize Count
  12155.  
  12156.   union {
  12157.     object { Rod translate Here*Count }
  12158.     #declare Count=Count+1           // re-declare inside union
  12159.     object { Rod translate Here*Count }
  12160.     #declare Count=Count+1           // re-declare inside union
  12161.     object { Rod translate Here*Count }
  12162.   }
  12163.  
  12164.  
  12165. As this example shows, you can re-declare an identifier and may use
  12166. previously declared values in that re-declaration. However if you attempt to
  12167. re-declare an identifier as anything other than its original type, it will
  12168. generate a warning message.
  12169.  
  12170. Declarations may be nested inside each other within limits. In the example in
  12171. the previous section you could declare the entire union as a object. However
  12172. for technical reasons you may not use any language directive inside the
  12173. declaration of floats, vectors or color expressions.
  12174.  
  12175. 7.2.3            Default Directive
  12176.  
  12177. POV-Ray creates a default texture when it begins processing. You may change
  12178. those defaults as described below. Every time you specify a texture
  12179. statement, POV-Ray creates a copy of the default texture. Anything you put in
  12180. the texture statement overrides the default settings. If you attach a
  12181. pigment, normal or finish to an object without any texture statement then
  12182. POV-Ray checks to see if a texture has already been attached. If it has a
  12183. texture then the pigment, normal or finish will modify the existing texture.
  12184. If no texture has yet been attached to the object then the default texture is
  12185. copied and the pigment, normal or finish will modify that texture.
  12186.  
  12187. You may change the default texture, pigment, normal or finish using the
  12188. language directive #default as follows:
  12189.  
  12190.   #default {
  12191.     texture {
  12192.       pigment {...}
  12193.       normal  {...}
  12194.       finish  {...}
  12195.     }
  12196.   }
  12197.  
  12198.  
  12199. Or you may change just part of it like this:
  12200.  
  12201.   #default {
  12202.     pigment {...}
  12203.   }
  12204.  
  12205.  
  12206. This still changes the pigment of the default texture. At any time there is
  12207. only one default texture made from the default pigment, normal and finish.
  12208. The example above does not make a separate default for pigments alone. Note
  12209. that the special textures tiles and material_map or a texture with a
  12210. texture_map may not be used as defaults.
  12211.  
  12212. You may change the defaults several times throughout a scene as you wish.
  12213. Subsequent #default statements begin with the defaults that were in effect at
  12214. the time. If you wish to reset to the original POV-Ray defaults then you
  12215. should first save them as follows:
  12216.  
  12217.   //At top of file
  12218.   #declare Original_Default = texture {}
  12219.  
  12220.  
  12221. later after changing defaults you may restore it with...
  12222.  
  12223.   #default {texture {Original_Default}}
  12224.  
  12225.  
  12226. If you do not specify a texture for an object then the default texture is
  12227. attached when the object appears in the scene. It is not attached when an
  12228. object is declared. For example:
  12229.  
  12230.   #declare My_Object =
  12231.     sphere{ <0,0,0>, 1 }  // Default texture not applied
  12232.   object { My_Object }    // Default texture added here
  12233.  
  12234.  
  12235. You may force a default texture to be added by using an empty texture
  12236. statement as follows:
  12237.  
  12238.   #declare My_Thing =
  12239.     sphere { <0,0,0>, 1 texture {} }  // Default texture applied
  12240.  
  12241.  
  12242. The original POV-Ray defaults for all items are given throughout the
  12243. documentation under each appropriate section.
  12244.  
  12245. 7.2.4            Version Directive
  12246.  
  12247. While many language changes have been made for POV-Ray 3.0, all of version
  12248. 2.0 syntax and most of version 1.0 syntax still works. Whenever possible we
  12249. try to maintain backwards compatibility. One feature introduced in 2.0 that
  12250. was incompatible with any 1.0 scene files is the parsing of float
  12251. expressions. Setting +MV1.0 command line switch or the Version=1.0 INI option
  12252. turns off expression parsing as well as many warning messages so that nearly
  12253. all 1.0 files will still work. The changes between 2.0 and 3.0 are not as
  12254. extensive. Setting Version=2.0 is only necessary to eliminate some warning
  12255. messages. Naturally the default setting for this option is Version=3.0.
  12256.  
  12257. The #version language directive is used to change modes within scene files.
  12258. This switch or INI options only affects the initial setting.
  12259.  
  12260. Together with the built-in version identifier the #version directive allows
  12261. you to save and restore the previous values of this compatibility setting.
  12262. For example suppose mystuff.inc is in version 1.0 format. At the top of the
  12263. file you could put:
  12264.  
  12265.   #declare Temp_Vers = version // Save previous value
  12266.   #version 1.0                    // Change to 1.0 mode
  12267.  
  12268.   ... // Version 1.0 stuff goes here ...
  12269.  
  12270.   #version Temp_Vers              // Restore previous version
  12271.  
  12272.  
  12273. Previous versions of POV-Ray would not allow you to change versions inside an
  12274. object or declaration but that restriction has been lifted for POV-Ray 3.0.
  12275.  
  12276. Future versions of POV-Ray may not continue to maintain full backward
  12277. compatibility even with the #version directive. We strongly encourage you to
  12278. phase in 3.0 syntax as much as possible.
  12279.  
  12280. 7.2.5            Conditional Directives
  12281.  
  12282. POV-Ray 3.0 allows a variety of new language directives to implement
  12283. conditional parsing of various sections of your scene file. This is
  12284. especially useful in describing the motion for animations but it has other
  12285. uses as well. Also available is a #while loop directive. You may nest
  12286. conditional directives 200 levels deep.
  12287.  
  12288. 7.2.5.1          IF ELSE Directives
  12289.  
  12290. The simplest conditional directive is a traditional #if directive. It is of
  12291. the form...
  12292.  
  12293.   #if (COND)
  12294.     // This section is
  12295.     //  parsed if COND is true
  12296.   #else
  12297.     // This section is
  12298.     // parsed if COND is false
  12299.   #end // End of conditional part
  12300.  
  12301.  
  12302. where (COND) is a float expression that evaluates to a boolean value. A value
  12303. of 0.0 is false and any non-zero value is true. Note that extremely small
  12304. values of about 1e-10 are considered zero in case of round off errors. The
  12305. parentheses around the condition are required. The #else directive is
  12306. optional. The #end directive is required.
  12307.  
  12308. 7.2.5.2          IFDEF Directives
  12309.  
  12310. The #ifdef directive is similar to the #if directive however it is used to
  12311. determine if an identifier has been previously declared. After the #ifdef
  12312. directive instead of a boolean expression you put a lone identifier enclosed
  12313. in parentheses. For example:
  12314.  
  12315.  #ifdef (User_Thing)
  12316.    // This section is parsed if the
  12317.    // identifier "User_Thing" was
  12318.    // previously declared
  12319.    object{User_Thing} // invoke identifier
  12320.  #else
  12321.    // This section is parsed if the
  12322.    // identifier "User_Thing" was not
  12323.    // previously declared
  12324.    box{<0,0,0>,<1,1,1>} // use a default
  12325.  #end
  12326.    // End of conditional part
  12327.  
  12328.  
  12329. 7.2.5.3          IFNDEF Directives
  12330.  
  12331. The #ifndef directive is similar to the #ifdef directive however it is used
  12332. to determine if the given identifier isn't declared yet. For example:
  12333.  
  12334.  #ifndef (User_Thing)
  12335.    // This section is parsed if the
  12336.    // identifier "User_Thing" was not
  12337.    // previously declared
  12338.    box{<0,0,0>,<1,1,1>} // use a default
  12339.  #else
  12340.    // This section is parsed if the
  12341.    // identifier "User_Thing" was
  12342.    // previously declared
  12343.    object{User_Thing} // invoke identifier
  12344.  #end
  12345.    // End of conditional part
  12346.  
  12347.  
  12348. 7.2.5.4          SWITCH CASE and RANGE Directives
  12349.  
  12350. A more powerful conditional is the #switch directive. The syntax is as
  12351. follows...
  12352.  
  12353.   #switch (VALUE)
  12354.     #case (TEST_1)
  12355.       // This section is parsed if VALUE=TEST_1
  12356.     #break  //First case ends
  12357.  
  12358.     #case (TEST_2)
  12359.       // This section is parsed if VALUE=TEST_2
  12360.     #break  //Second case ends
  12361.  
  12362.     #range (LOW_1,HIGH_1)
  12363.       // This section is parsed if (VALUE>=LOW_1)&(VALUE<=HIGH_1)
  12364.     #break  //Third case ends
  12365.  
  12366.     #range (LOW_2,HIGH_2)
  12367.       // This section is parsed if (VALUE>=LOW_2)&(VALUE<=HIGH_2)
  12368.     #break  //Fourth case ends
  12369.  
  12370.     #else
  12371.       // This section is parsed if no other case or
  12372.       // range is true.
  12373.   #end // End of conditional part
  12374.  
  12375.  
  12376. The float expression VALUE following the #switch directive is evaluated and
  12377. compared to the values in the #case or #range directives. When using #case,
  12378. it is followed by a float expression TEST_1 in parentheses. It is compared to
  12379. the VALUE. As usual in POV-Ray, float comparisons are considered equal if
  12380. their difference is under 1e-10. If the values are equal, parsing continues
  12381. normally until a #break, #else or #end directive is reached. If the
  12382. comparison fails POV-Ray skips until another #case or #range is found.
  12383.  
  12384. If you use the #range directive it is followed by two float expressions LOW_1
  12385. and HIGH_1 which are enclosed in parentheses and separated by a comma. If the
  12386. switch VALUE is in the range specified then parsing continues normally until
  12387. a #break, #else or #end directive is reached. If the VALUE is outside the
  12388. range the comparison fails and POV-Ray skips until another #case or #range is
  12389. found.
  12390.  
  12391. If no #case or #range succeeds the #else section is parsed. The #else
  12392. directive is optional. If no #else is specified and no match succeeds then
  12393. parsing resumes after the #end directive.
  12394.  
  12395. There may be any number of #case or #range directives in any order you want.
  12396. If a segment evaluates true but no #break is specified, the parsing will fall
  12397. through to the next #case or #range and will continue until a #break, #else
  12398. or #end. Hitting a #break while parsing a successful section causes an
  12399. immediate jump to the #end without processing subsequent sections, even if a
  12400. subsequent condition would also have been satisfied.
  12401.  
  12402. 7.2.5.5          WHILE Directive
  12403.  
  12404. The #while directive is a looping feature that makes it easy to place
  12405. multiple objects in a pattern or other uses. The #while directive is followed
  12406. by a float expression that evaluates to a boolean value. A value of 0.0 is
  12407. false and any non-zero value is true. Note that extremely small values of
  12408. about 1e-10 are considered zero in case of round off errors. The parentheses
  12409. around the expression are required. If the condition is true parsing
  12410. continues normally until an #end directive is reached. At the end, POV-Ray
  12411. loops back to the #while directive and the condition is re-evaluated. Looping
  12412. continues until the condition fails. When it fails, parsing continues after
  12413. the #end directive. For example:
  12414.  
  12415.   #declare Count=0
  12416.   #while (Count < 5)
  12417.     object{MyObject translate x*3*Count}
  12418.     #declare Count=Count+1
  12419.   #end
  12420.  
  12421.  
  12422. This example places five copies of MyObject in a row spaced three units apart
  12423. in the x-direction.
  12424.  
  12425. 7.2.6            User Message Directives
  12426.  
  12427. With the addition of conditional and loop directives, the POV-Ray language
  12428. has the potential to be more like an actual programming language. This means
  12429. that it will be necessary to have some way to see what is going on when
  12430. trying to debug loops and conditionals. To fulfill this need we have added
  12431. the ability to print text messages to the screen. You have a choice of five
  12432. different text streams to use including the ability to generate a fatal error
  12433. if you find it necessary. Limited formatting is available for strings output
  12434. by this method.
  12435.  
  12436. 7.2.6.1          Text Message Streams
  12437.  
  12438. The syntax for a text message is any of the following:
  12439.  
  12440.   #debug      STRING
  12441.   #error      STRING
  12442.   #render     STRING
  12443.   #statistics STRING
  12444.   #warning    STRING
  12445.  
  12446.  
  12447. Where STRING is any valid string of text including string identifiers or
  12448. functions which return strings. For example:
  12449.  
  12450.   #switch (clock*360)
  12451.     #range (0,180)
  12452.       #render "Clock in 0 to 180 range\n"
  12453.     #break
  12454.  
  12455.     #range (180,360)
  12456.       #render "Clock in 180 to 360 range\n"
  12457.     #break
  12458.  
  12459.     #else
  12460.       #warning "Clock outside expected range\n"
  12461.       #warning concat("Value is:",str(clock*360,5,0),"\n")
  12462.   #end
  12463.  
  12464.  
  12465. There are seven distinct text streams that POV-Ray uses for output. You may
  12466. output only to five of them. On some versions of POV-Ray, each stream is
  12467. designated by a particular color. Text from these streams are displayed
  12468. whenever it is appropriate so there is often an intermixing of the text. The
  12469. distinction is only important if you choose to turn some of the streams off
  12470. or to direct some of the streams to text files. On some systems you may be
  12471. able to review the streams separately in their own scroll-back buffer. See
  12472. "Console Text Output" for details on re-directing the streams to a text file.
  12473.  
  12474.  
  12475. Here is a description of how POV-Ray uses each stream. You may use them for
  12476. whatever purpose you want except note that use of the #error stream causes a
  12477. fatal error after the text is displayed.
  12478.  
  12479. DEBUG: This stream displays debugging messages. It was primarily designed for
  12480. developers but this and other streams may also be used by the user to display
  12481. messages from within their scene files.
  12482.  
  12483. FATAL: This stream displays fatal error messages. After displaying this text,
  12484. POV-Ray will terminate. When the error is a scene parsing error, you may be
  12485. shown several lines of scene text that leads up to the error.
  12486.  
  12487. RENDER: This stream displays information about what options you have
  12488. specified to render the scene. It includes feedback on all of the major
  12489. options such as scene name, resolution, animation settings, anti-aliasing and
  12490. others.
  12491.  
  12492. STATISTICS: This stream displays statistics after a frame is rendered. It
  12493. includes information about the number of rays traced, the length of time of
  12494. the processing and other information.
  12495.  
  12496. WARNING: This stream displays warning messages during the parsing of scene
  12497. files and other warnings. Despite the warning, POV-Ray can continue to render
  12498. the scene.
  12499.  
  12500.  
  12501. 7.2.6.2          Text Formatting
  12502.  
  12503. Some escape sequences are available to include non-printing control
  12504. characters in your text. These sequences are similar to those used in string
  12505. literals in the C programming language. The sequences are:
  12506.  
  12507.   "\""Double quote 0x2209D 0x0A
  12508.  
  12509.  
  12510. For example:
  12511.  
  12512.   #debug "This is one line.\nBut this is another"
  12513.  
  12514.  
  12515. Depending on what platform you are using, they may not be fully supported for
  12516. console output. However they will appear in any text file if you re-direct a
  12517. stream to a file.
  12518.  
  12519. Note that most of these control characters only apply in text message
  12520. directives. They are not implemented for other string usage in POV-Ray such
  12521. as text objects or file names.
  12522.  
  12523. The exceptions are the
  12524.  
  12525.  
  12526. 7.3              POV-Ray Coordinate System
  12527.  
  12528. Objects, lights and the camera are positioned using a typical 3D coordinate
  12529. system. The usual coordinate system for POV-Ray has the positive y-axis
  12530. pointing up, the positive x-axis pointing to the right and the positive
  12531. z-axis pointing into the screen. The negative values of the axes point the
  12532. other direction as shown in the images in section "Understanding POV-Ray's
  12533. Coordinate System".
  12534.  
  12535. Locations within that coordinate system are usually specified by a three
  12536. component vector. The three values correspond to the x, y and z directions
  12537. respectively. For example, the vector < 1,2,3> means the point that's one
  12538. unit to the right, two units up and three units in front of the center of the
  12539. universe at <0,0,0>.
  12540.  
  12541. Vectors are not always points though. They can also refer to an amount to
  12542. size, move or rotate a scene element or to modify the texture pattern applied
  12543. to an object.
  12544.  
  12545. The supported transformations are rotate, scale and translate. They are used
  12546. to turn, size and translate an object or texture. A transformation matrix may
  12547. also be used to specify complex transformations directly.
  12548.  
  12549. 7.3.1            Transformations
  12550.  
  12551. The supported transformations are rotate, scale and translate. They are used
  12552. to turn, size and translate an object or texture.
  12553.  
  12554.   rotate <VECTOR>
  12555.   scale <VECTOR>
  12556.   translate <VECTOR>
  12557.  
  12558.  
  12559. 7.3.1.1          Translate
  12560.  
  12561. An object or texture pattern may be moved by adding a translate parameter. It
  12562. consists of the keyword translate followed by a vector expression. The terms
  12563. of the vector specify the number of units to move in each of the x, y and z
  12564. directions. Translate moves the element relative to it's current position.
  12565. For example
  12566.  
  12567.   sphere { <10, 10, 10>, 1
  12568.     pigment { Green }
  12569.     translate <-5, 2, 1>
  12570.   }
  12571.  
  12572.  
  12573. will move the sphere from <10,10,10> to < 5,12,11>. It does not move it to
  12574. the absolute location <-5,2,1>. Translating by zero will leave the element
  12575. unchanged on that axis. For example:
  12576.  
  12577.   sphere { <10, 10, 10>, 1
  12578.     pigment { Green }
  12579.     translate 3*x // evaluates to <3,0,0> so move 3 units
  12580.                   // in the x direction and none along y or z
  12581.   }
  12582.  
  12583.  
  12584. 7.3.1.2          Scale
  12585.  
  12586. You may change the size of an object or texture pattern by adding a scale
  12587. parameter. It consists of the keyword scale followed by a vector expression.
  12588. The 3 terms of the vector specify the amount of scaling in each of the x, y
  12589. and z directions.
  12590.  
  12591. Scale is used to stretch or squish an element. Values larger than one stretch
  12592. the element on that axis while values smaller than one are used to squish it.
  12593. Scale is relative to the current element size. If the element has been
  12594. previously re-sized using scale then scale will size relative to the new
  12595. size. Multiple scale values may used.
  12596.  
  12597. For example
  12598.  
  12599.   sphere { <0,0,0>, 1
  12600.     scale <2,1,0.5>
  12601.   }
  12602.  
  12603.  
  12604. will stretch and smash the sphere into an ellipsoid shape that is twice the
  12605. original size along the x-direction, remains the same size in the y-direction
  12606. and is half the original size in the z-direction.
  12607.  
  12608. If a lone float expression is specified it is promoted to a three component
  12609. vector whose terms are all the same. Thus the item is uniformly scaled by the
  12610. same amount in all directions. For example:
  12611.  
  12612.   object {
  12613.     MyObject
  12614.     scale 5 // Evaluates as <5,5,5> so uniformly scale
  12615.             // by 5 in every direction.
  12616.   }
  12617.  
  12618.  
  12619. 7.3.1.3          Rotate
  12620.  
  12621. You may change the orientation of an object or texture pattern by adding a
  12622. rotate parameter. It consists of the keyword rotate followed by a vector
  12623. expression. The three terms of the vector specify the number of degrees to
  12624. rotate about each of the x-, y- and z-axes.
  12625.  
  12626. Note that the order of the rotations does matter. Rotations occur about the
  12627. x-axis first, then the y-axis, then the z-axis. If you are not sure if this
  12628. is what you want then you should only rotate on one axis at a time using
  12629. multiple rotation statements to get a correct rotation. As in
  12630.  
  12631.   rotate <0, 30, 0>  // 30 degrees around Y axis then,
  12632.   rotate <-20, 0, 0> // -20 degrees around X axis then,
  12633.   rotate <0, 0, 10>  // 10 degrees around Z axis.
  12634.  
  12635.  
  12636. Rotation is always performed relative to the axis. Thus if an object is some
  12637. distance from the axis of rotation it will not only rotate but it will orbit
  12638. about the axis as though it was swinging around on an invisible string.
  12639.  
  12640. To work out the rotation directions you must perform the famous Computer
  12641. Graphics Aerobics exercise as explained in the section "Understanding
  12642. POV-Ray's Coordinate System".
  12643.  
  12644. 7.3.1.4          Matrix Keyword
  12645.  
  12646. The matrix keyword can be used to explicitly specify the transformation
  12647. matrix to be used for objects or textures. Its syntax is:
  12648.  
  12649.   matrix < m00, m01, m02,
  12650.            m10, m11, m12,
  12651.            m20, m21, m22,
  12652.            m30, m31, m32 >
  12653.  
  12654.  
  12655. Where m00 through m32 are float expressions that specify the elements of a
  12656. 4*4 matrix with the fourth column implicitly set to <0,0,0,1>. A point P,
  12657. P=<px, py, pz>, is transformed into Q, Q=<qx, qy, qz> by
  12658.  
  12659.   qx = M00 * px + M10 * py + M20 * pz + M30
  12660.   qy = M01 * px + M11 * py + M21 * pz + M31
  12661.   qz = M02 * px + M12 * py + M22 * pz + M32
  12662.  
  12663.  
  12664. Normally you won't use the matrix keyword because it's less descriptive than
  12665. the transformation commands and harder to visualize. There is an intersecting
  12666. aspect of the matrix command though. It allows more general transformation
  12667. like shearing. The following matrix causes an object to be sheared along the
  12668. y-axis.
  12669.  
  12670.   object {
  12671.     MyObject
  12672.     matrix < 1, 1, 0,
  12673.              0, 1, 0,
  12674.              0, 0, 1,
  12675.              0, 0, 0 >
  12676.   }
  12677.  
  12678.  
  12679. 7.3.2            Transformation Order
  12680.  
  12681. Because rotations are always relative to the axis and scaling is relative to
  12682. the origin, you will generally want to create an object at the origin and
  12683. scale and rotate it first. Then you may translate it into its proper
  12684. position. It is a common mistake to carefully position an object and then to
  12685. decide to rotate it because a rotation of an object causes it to orbit about
  12686. the axis, the position of the object may change so much that it orbits out of
  12687. the field of view of the camera!
  12688.  
  12689. Similarly scaling after translation also moves an object unexpectedly. If you
  12690. scale after you translate the scale will multiply the translate amount. For
  12691. example
  12692.  
  12693.   translate <5, 6, 7>
  12694.   scale 4
  12695.  
  12696.  
  12697. will translate to <20,24,28> instead of < 5,6,7>. Be careful when
  12698. transforming to get the order correct for your purposes.
  12699.  
  12700. 7.3.3            Transform Identifiers
  12701.  
  12702. At times it is useful to combine together several transformations and apply
  12703. them in multiple places. A transform identifier may be used for this purpose.
  12704. Transform identifiers are declared as follows:
  12705.  
  12706.   #declare IDENT = transform { TRANSFORMATION... }
  12707.  
  12708.  
  12709. Where IDENT is the identifier to be declared and TRANSFORMATION is one or
  12710. more translate, rotate, scale or matrix specifications or a previously
  12711. declared transform identifier. A transform identifier is invoked by the
  12712. transform keyword without any brackets as shown here:
  12713.  
  12714.   object {
  12715.     MyObject           // Get a copy of MyObject
  12716.     transform MyTrans  // Apply the transformation
  12717.     translate -x*5     // Then move it 5 units left
  12718.   }
  12719.   object {
  12720.     MyObject           // Get another copy of MyObject
  12721.     transform MyTrans  // Apply the same transformation
  12722.     translate -x*5     // Then move this one 5 units right
  12723.   }
  12724.  
  12725.  
  12726. On extremely complex CSG objects with lots of components it may speed up
  12727. parsing if you apply a declared transformation rather than the individual
  12728. translate, rotate, scale or matrix specifications. The transform is attached
  12729. just once to each component. Applying each individual translate, rotate,
  12730. scale or matrix specifications takes long. This only affects parsing -
  12731. rendering works the same either way.
  12732.  
  12733. 7.3.4            Transforming Textures and Objects
  12734.  
  12735. When an object is transformed all textures attached to the object at that
  12736. time are transformed as well. This means that if you have a translate,
  12737. rotate, scale or matrix in an object before a texture the texture will not be
  12738. transformed. If the transformation is after the texture then the texture will
  12739. be transformed with the object. If the transformation is inside the texture
  12740. statement then only the texture is affected. The shape remains the same. For
  12741. example:
  12742.  
  12743.   sphere { 0, 1
  12744.     texture { Jade }  // texture identifier from TEXTURES.INC
  12745.     scale 3           // this scale affects both the
  12746.                       // shape and texture
  12747.   }
  12748.  
  12749.   sphere { 0, 1
  12750.     scale 3           // this scale affects the shape only
  12751.     texture { Jade }
  12752.   }
  12753.  
  12754.   sphere { 0, 1
  12755.     texture {
  12756.       Jade
  12757.       scale 3         // this scale affects the texture only
  12758.     }
  12759.   }
  12760.  
  12761.  
  12762. Transformations may also be independently applied to pigment patterns and
  12763. surface normal patterns. Note that scaling a normal pattern affects only the
  12764. width and spacing. It does not affect the apparent height or depth of the
  12765. bumps. For example:
  12766.  
  12767.   box { <0, 0, 0>, <1, 1, 1>
  12768.     texture {
  12769.       pigment {
  12770.         checker Red, White
  12771.         scale 0.25 // This affects only the color pattern
  12772.       }
  12773.       normal {
  12774.         bumps 0.3  // This specifies apparent height of bumps
  12775.         scale 0.2  // Scales diameter and space between bumps
  12776.                    // but not the height. Has no effect on
  12777.                    // color pattern.
  12778.       }
  12779.       rotate y*45  // This affects the entire texture but
  12780.     }              // not the object.
  12781.   }
  12782.  
  12783.  
  12784. 7.4              Camera
  12785.  
  12786. The camera definition describes the position, projection type and properties
  12787. of the camera viewing the scene. Its syntax is:
  12788.  
  12789.   camera {
  12790.     [ perspective | orthographic | fisheye |
  12791.       ultra_wide_angle | omnimax | panoramic |
  12792.       cylinder FLOAT ]
  12793.     location <VECTOR>
  12794.     look_at <VECTOR>
  12795.     right <VECTOR>
  12796.     up <VECTOR>
  12797.     direction <VECTOR>
  12798.     sky <VECTOR>
  12799.     right <VECTOR>
  12800.     angle FLOAT
  12801.     blur_samples FLOAT
  12802.     aperture FLOAT
  12803.     focal_point <VECTOR>
  12804.     normal { NORMAL }
  12805.   }
  12806.  
  12807.  
  12808. Depending on the projection type some of the parameters are required, some
  12809. are optional and some aren't used. If no projection type is given the
  12810. perspective camera will be used (pinhole camera). If no camera is specified a
  12811. default camera is used.
  12812.  
  12813. Regardless of the projection type all cameras use the location, look_at,
  12814. right, up, direction and sky keywords to determine the location and
  12815. orientation of the camera. Their meaning differs with the projection type
  12816. used. A more detailed explanation of the camera placement follows later.
  12817.  
  12818. 7.4.1            Type of Projection
  12819.  
  12820. The following list explains the different projection types that can be used
  12821. with the camera. The most common types are the perspective and orthographic
  12822. projections.
  12823.  
  12824. Perspective projection: This projection represents the classic pinhole
  12825. camera. The (horizontal) viewing angle is either determined by the ratio
  12826. between the length of the direction vector and the length of the right vector
  12827. or by the optional keyword angle, which is the preferred way. The viewing
  12828. angle has to be larger than 0 degrees and smaller than 180 degrees. See the
  12829. figure below for the geometry of the perspective camera.
  12830.  
  12831. The perspective camera.
  12832.  
  12833. Orthographic projection: This projection uses parallel camera rays to create
  12834. an image of the scene. The size of the image is determined by the lengths of
  12835. the right and up vectors.
  12836.  
  12837. If you add the orthographic keyword after all other parameters of a
  12838. perspective camera you'll get an orthographic view with the same image area,
  12839. i.e. the size of the image is the same. In this case you needn't specify the
  12840. lengths of the right and up vector because they'll be calculated
  12841. automatically. You should be aware though that the visible parts of the scene
  12842. change when switching from perspective to orthographic view. As long as all
  12843. objects of interest are near the look_at location they'll be still visible if
  12844. the orthographic camera is used. Objects farther away may get out of view
  12845. while nearer objects will stay in view.
  12846.  
  12847. Fisheye projection: This is a spherical projection. The viewing angle is
  12848. specified by the angle keyword. An angle of 180 degrees creates the
  12849. "standard" fisheye while an angle of 360 degrees creates a super-fisheye
  12850. ("I-see-everything-view"). If you use this projection you should get a
  12851. circular image. If this isn't the case, i.e. you get an elliptical image, you
  12852. should read "Aspect Ratio".
  12853.  
  12854. Ultra wide angle projection: This projection is somewhat similar to the
  12855. fisheye but it projects the image onto a rectangle instead of a circle. The
  12856. viewing angle can be specified using the angle keyword.
  12857.  
  12858. Omnimax projection: The omnimax projection is a 180 degrees fisheye that has
  12859. a reduced viewing angle in the vertical direction. In reality this projection
  12860. is used to make movies that can be viewed in the dome-like Omnimax theaters.
  12861. The image will look somewhat elliptical. The angle keyword isn't used with
  12862. this projection.
  12863.  
  12864. Panoramic projection: This projection is called "cylindrical equirectangular
  12865. projection". It overcomes the degeneration problem of the perspective
  12866. projection if the viewing angle approaches 180 degrees. It uses a type of
  12867. cylindrical projection to be able to use viewing angles larger than 180
  12868. degrees with a tolerable lateral-stretching distortion. The angle keyword is
  12869. used to determine the viewing angle.
  12870.  
  12871. Cylindrical projection: Using this projection the scene is projected onto a
  12872. cylinder. There are four different types of cylindrical projections depending
  12873. on the orientation of the cylinder and the position of the viewpoint. The
  12874. viewing angle and the length of the up or right vector determine the
  12875. dimensions of the camera and the visible image. The camera to use is
  12876. specified by a number. The types are:
  12877.  
  12878.   4 horizontal cylinder, viewpoint moves along the cylinder's axis
  12879.  
  12880.  
  12881. If the perspective camera is used the angle keyword overrides the viewing
  12882. angle specified by the direction keyword and vice versa. Each time angle is
  12883. used the length of the direction vector is adjusted to fit the new viewing
  12884. angle.
  12885.  
  12886. There is no limitation to the viewing angle except for the perspective
  12887. projection. If you choose viewing angles larger than 360 degrees you'll see
  12888. repeated images of the scene (the way the repetition takes place depends on
  12889. the camera). This might be useful for special effects.
  12890.  
  12891. You should note that the vista buffer can only be used with the perspective
  12892. and orthographic camera.
  12893.  
  12894. 7.4.2            Focal Blur
  12895.  
  12896. Simulates focal depth-of-field by shooting a number of sample rays from
  12897. jittered points within each pixel and averaging the results.
  12898.  
  12899. The aperture keyword determines the depth of the sharpness zone. Large
  12900. apertures give a lot of blurring, while narrow apertures will give a wide
  12901. zone of sharpness. Note that, while this behaves as a real camera does, the
  12902. values for aperture are purely arbitrary and are not related to f-stops.
  12903.  
  12904. The center of the zone of sharpness is the focal_point vector (the default
  12905. focal_point is <0,0,0>).
  12906.  
  12907. The blur_samples value controls the maximum number of rays to use for each
  12908. pixel. More rays give a smoother appearance but is slower, although this is
  12909. controlled somewhat by an adaptive mechanism that stops shooting rays when a
  12910. certain degree of confidence has been reached that shooting more rays would
  12911. not result in a significant change.
  12912.  
  12913. The confidence and variance keywords control the adaptive function. The
  12914. confidence value is used to determine when the samples seem to be close
  12915. enough to the correct color. The variance value specifies an acceptable
  12916. tolerance on the variance of the samples taken so far. In other words, the
  12917. process of shooting sample rays is terminated when the estimated color value
  12918. is very likely (as controlled by the confidence probability) near the real
  12919. color value.
  12920.  
  12921. Since the confidence is a probability its values can range from 0 to 1 (the
  12922. default is 0.9, i. e. 90%). The value for the variance should be in the range
  12923. of the smallest displayable color difference (the default is 1/128).
  12924.  
  12925. Larger confidence values will lead to more samples, slower traces and better
  12926. images. The same holds for smaller variance thresholds.
  12927.  
  12928. By default no focal blur is used, i. e. the default aperture is 0 and the
  12929. default number of samples is 0.
  12930.  
  12931. 7.4.3            Camera Ray Perturbation
  12932.  
  12933. The optional keyword normal may be used to assign a normal pattern to the
  12934. camera. All camera rays will be perturbed using this pattern. This lets you
  12935. create special effects. See the animated scene camera2.pov for an example.
  12936.  
  12937. 7.4.4            Placing the Camera
  12938.  
  12939. In the following sections the placing of the camera will be further
  12940. explained.
  12941.  
  12942. 7.4.4.1          Location and Look_At
  12943.  
  12944. Under many circumstances just two vectors in the camera statement are all you
  12945. need to position the camera: location and look_at. For example:
  12946.  
  12947.   camera {
  12948.     location <3,5,-10>
  12949.     look_at  <0,2,1>
  12950.   }
  12951.  
  12952.  
  12953. The location is simply the x, y, z coordinates of the camera. The camera can
  12954. be located anywhere in the ray-tracing universe. The default location is <0,
  12955. 0, 0>. The look_at vector tells POV-Ray to pan and tilt the camera until it
  12956. is looking at the specified x, y, z coordinates. By default the camera looks
  12957. at a point one unit in the z-direction from the location.
  12958.  
  12959. The look_at specification should almost always be the last item in the camera
  12960. statement. If other camera items are placed after the look_at vector then the
  12961. camera may not continue to look at the specified point.
  12962.  
  12963. 7.4.4.2          The Sky Vector
  12964.  
  12965. Normally POV-Ray pans left or right by rotating about the y-axis until it
  12966. lines up with the look_at point and then tilts straight up or down until the
  12967. point is met exactly. However you may want to slant the camera sideways like
  12968. an airplane making a banked turn. You may change the tilt of the camera using
  12969. the sky vector. For example:
  12970.  
  12971.   camera {
  12972.     location <3,5,-10>
  12973.     sky      <1,1,0>
  12974.     look_at  <0,2,1>
  12975.   }
  12976.  
  12977.  
  12978. This tells POV-Ray to roll the camera until the top of the camera is in line
  12979. with the sky vector. Imagine that the sky vector is an antenna pointing out
  12980. of the top of the camera. Then it uses the sky vector as the axis of rotation
  12981. left or right and then to tilt up or down in line with the sky vector. In
  12982. effect you're telling POV-Ray to assume that the sky isn't straight up. Note
  12983. that the sky vector must appear before the look_at vector.
  12984.  
  12985. The sky vector does nothing on its own. It only modifies the way the look_at
  12986. vector turns the camera. The default value for sky is <0, 1, 0>.
  12987.  
  12988. 7.4.4.3          The Direction Vector
  12989.  
  12990. The direction vector tells POV-Ray the initial direction to point the camera
  12991. before moving it with look_at or rotate vectors (the default is direction <0,
  12992. 0, 1>). It may also be used to control the (horizontal) field of view with
  12993. some types of projection. This should be done using the easier to use angle
  12994. keyword though.
  12995.  
  12996. If you are using the ultra wide angle, panoramic or cylindrical projection
  12997. you should use a unit length direction vector to avoid strange results.
  12998.  
  12999. The length of the direction vector doesn't matter if one of the following
  13000. projection types is used: orthographic, fisheye or omnimax.
  13001.  
  13002. 7.4.4.4          Angle
  13003.  
  13004. The angle keyword specifies the (horizontal) viewing angle in degrees of the
  13005. camera used. Even though it is possible to use the direction vector to
  13006. determine the viewing angle for the perspective camera it is much easier to
  13007. use the angle keyword.
  13008.  
  13009. The necessary calculations to convert from one method to the other are
  13010. described below. These calculations are used to determine the length of the
  13011. direction vector whenever the angle keyword is encountered.
  13012.  
  13013. The viewing angle is converted to a direction vector length and vice versa
  13014. using the formula The viewing angle is given by the formula
  13015.  
  13016.   angle = 2 * arctan(0.5 * right_length / direction_length)
  13017.  
  13018.  
  13019. where right_length and direction_length are the lengths of the right and
  13020. direction vector respectively and arctan is the inverse tangens function.
  13021.  
  13022. From this the length of the direction vector can be calculated for a given
  13023. viewing angle and right vector.
  13024.  
  13025. From this the length of the direction vector can be calculated for a given
  13026. viewing angle and right vector.
  13027.  
  13028.   direction_length = 0.5 * right_length / tan(angle / 2)
  13029.  
  13030.  
  13031. 7.4.4.5          Up and Right Vectors
  13032.  
  13033. The direction of the up and right vectors (together with the direction
  13034. vector) determine the orientation of the camera in the scene. They are set
  13035. implicitly by their default values of
  13036.  
  13037.   right 4/3*x
  13038.   up y
  13039.  
  13040.  
  13041. or the look_at parameter (in combination with location). The directions of an
  13042. explicitly specified right and up vector will be overridden by any following
  13043. look_at parameter.
  13044.  
  13045. While some camera types ignore the length of these vectors others use it to
  13046. extract valuable information about the camera settings. The following list
  13047. will explain the meaning of the right and up vector for each camera type.
  13048. Since the direction the vectors is always used to describe the orientation of
  13049. the camera it will not be explained again.
  13050.  
  13051. Perspective projection: The lengths of the up and right vectors are used to
  13052. set the size of the viewing window and the aspect ratio as described in
  13053. detail in section "Aspect Ratio". Since the field of view depends on the
  13054. length of the direction vector (implicitly set by the angle keyword or
  13055. explicitly set by the direction keyword) and the lengths of the right and up
  13056. vectors you should carefully choose them in order to get the desired results.
  13057.  
  13058.  
  13059. Orthographic projection: The lengths of the right and up vector set the size
  13060. of the viewing window regardless of the direction vector length, which is not
  13061. used by the orthographic camera. Again the relation of the lengths is used to
  13062. set the aspect ratio.
  13063.  
  13064. Fisheye projection: The right and up vectors are used to set the aspect
  13065. ratio.
  13066.  
  13067. Ultra wide angle projection: The up and right vectors work in a similar way
  13068. as for the perspective camera.
  13069.  
  13070. Omnimax projection: The omnimax projection is a 180 degrees fisheye that has
  13071. a reduced viewing angle in the vertical direction. In reality this projection
  13072. is used to make movies that can be viewed in the dome-like Omnimax theaters.
  13073. The image will look somewhat elliptical. The angle keyword isn't used with
  13074. this projection.
  13075.  
  13076. Panoramic projection: The up and right vectors work in a similar way as for
  13077. the perspective camera.
  13078.  
  13079. Cylindrical projection: In cylinder type 1 and 3 the axis of the cylinder
  13080. lies along the up vector and the width is determined by the length of right
  13081. vector or it may be overridden with the angle vector. In type 3 the up vector
  13082. determines how many units high the image is. For example if you have up 4*y
  13083. on a camera at the origin. Only points from y=2 to y=-2 are visible. All
  13084. viewing rays are perpendicular to the y-axis. For type 2 and 4, the cylinder
  13085. lies along the right vector. Viewing rays for type 4 are perpendicular to the
  13086. right vector.
  13087.  
  13088. Note that the up, right and direction vectors should always remain
  13089. perpendicular to each other or the image will be distorted. If this is not
  13090. the case a warning message will be printed. The vista buffer will not work
  13091. for non-perpendicular camera vectors.
  13092.  
  13093. 7.4.4.5.1        Aspect Ratio
  13094.  
  13095. Together the right and up vectors define the aspect ratio (height to width
  13096. ratio) of the resulting image. The default values up  <0, 1, 0> and right
  13097. <1.33, 0,  0> result in an aspect ratio of 4 to 3. This is the aspect ratio
  13098. of a typical computer monitor. If you wanted a tall skinny image or a short
  13099. wide panoramic image or a perfectly square image you should adjust the up and
  13100. right vectors to the appropriate proportions.
  13101.  
  13102. Most computer video modes and graphics printers use perfectly square pixels.
  13103. For example Macintosh displays and IBM SVGA modes 640x480, 800x600 and
  13104. 1024x768 all use square pixels. When your intended viewing method uses square
  13105. pixels then the width and height you set with the +W and +H switches should
  13106. also have the same ratio as the right and up vectors. Note that 640/480 = 4/3
  13107. so the ratio is proper for this square pixel mode.
  13108.  
  13109. Not all display modes use square pixels however. For example IBM VGA mode
  13110. 320x200 and Amiga 320x400 modes do not use square pixels. These two modes
  13111. still produce a 4/3 aspect ratio image. Therefore images intended to be
  13112. viewed on such hardware should still use 4/3 ratio on their up and right
  13113. vectors but the +W and +H settings will not be 4/3.
  13114.  
  13115. For example:
  13116.  
  13117.   camera {
  13118.     location <3,5,-10>
  13119.     up       <0,1,0>
  13120.     right    <1,0,0>
  13121.     look_at  <0,2,1>
  13122.   }
  13123.  
  13124.  
  13125. This specifies a perfectly square image. On a square pixel display like SVGA
  13126. you would use +W and +H settings such as +W480 +H480 or +W600 +H600. However
  13127. on the non-square pixel Amiga 320x400 mode you would want to use values of
  13128. +W240 +H400 to render a square image.
  13129.  
  13130. 7.4.4.5.2        Handedness
  13131.  
  13132. The right vector also describes the direction to the right of the camera. It
  13133. tells POV-Ray where the right side of your screen is. The sign of the right
  13134. vector can be used to determine the handedness of the coordinate system in
  13135. use. The default right statement is:
  13136.  
  13137.   right <1.33, 0, 0>
  13138.  
  13139.  
  13140. This means that the +x-direction is to the right. It is called a left-handed
  13141. system because you can use your left hand to keep track of the axes. Hold out
  13142. your left hand with your palm facing to your right. Stick your thumb up.
  13143. Point straight ahead with your index finger. Point your other fingers to the
  13144. right. Your bent fingers are pointing to the +x-direction. Your thumb now
  13145. points into +y-direction. Your index finger points into the +z-direction.
  13146.  
  13147. To use a right-handed coordinate system, as is popular in some CAD programs
  13148. and other ray-tracers, make the same shape using your right hand. Your thumb
  13149. still points up in the +y-direction and your index finger still points
  13150. forward in the +z-direction but your other fingers now say the +x-direction
  13151. is to the left. That means that the right side of your screen is now in the
  13152. -x-direction. To tell POV-Ray to act like this you can use a negative x value
  13153. in the right vector like this:
  13154.  
  13155.   right <-1.33, 0, 0>
  13156.  
  13157.  
  13158. Since x increasing to the left doesn't make much sense on a 2D screen you now
  13159. rotate the whole thing 180 degrees around by using a positive z value in your
  13160. camera's location. You end up with something like this.
  13161.  
  13162.   camera {
  13163.     location <0,0,10>
  13164.     up       <0,1,0>
  13165.     right    <-1.33,0,0>
  13166.     look_at  <0,0,0>
  13167.   }
  13168.  
  13169.  
  13170. Now when you do your ray-tracer's aerobics, as explained in the section
  13171. "Understanding POV-Ray's Coordinate System", you use your right hand to
  13172. determine the direction of rotations.
  13173.  
  13174. In a two dimensional grid, x is always to the right and y is up. The two
  13175. versions of handedness arise from the question of whether z points into the
  13176. screen or out of it and which axis in your computer model relates to up in
  13177. the real world.
  13178.  
  13179. Architectural CAD systems, like AutoCAD, tend to use the God's  Eye
  13180. orientation that the z-axis is the elevation and is the model's up direction.
  13181. This approach makes sense if you're an architect looking at a building
  13182. blueprint on a computer screen. z means up, and it increases towards you,
  13183. with x and y still across and up the screen. This is the basic right handed
  13184. system.
  13185.  
  13186. Stand alone rendering systems, like POV-Ray, tend to consider you as a
  13187. participant. You're looking at the screen as if you were a photographer
  13188. standing in the scene. Up in the model is now y, the same as up in the real
  13189. world and x is still to the right, so z must be depth, which increases away
  13190. from you into the screen. This is the basic left handed system.
  13191.  
  13192. 7.4.4.6          Transforming the Camera
  13193.  
  13194. The translate and rotate commands can re-position the camera once you've
  13195. defined it. For example:
  13196.  
  13197.   camera {
  13198.     location  < 0,  0,  0>
  13199.     direction < 0,  0,  1>
  13200.     up        < 0,  1,  0>
  13201.     right     < 1,  0,  0>
  13202.     rotate    <30, 60, 30>
  13203.     translate < 5,  3,  4>
  13204.   }
  13205.  
  13206.  
  13207. In this example, the camera is created, then rotated by 30 degrees about the
  13208. x-axis, 60 degrees about the y-axis and 30 degrees about the z-axis, then
  13209. translated to another point in space.
  13210.  
  13211. 7.4.5            Camera Identifiers
  13212.  
  13213. You may declare several camera identifiers if you wish. This makes it easy to
  13214. quickly change cameras. For example:
  13215.  
  13216.   #declare Long_Lens =
  13217.     camera {
  13218.       location -z*100
  13219.       angle 3
  13220.     }
  13221.  
  13222.   #declare Short_Lens =
  13223.     camera {
  13224.       location -z*50
  13225.       angle 15
  13226.     }
  13227.  
  13228.   camera {
  13229.     Long_Lens    // edit this line to change lenses
  13230.     look_at Here
  13231.   }
  13232.  
  13233.  
  13234. 7.5              Objects
  13235.  
  13236. Objects are the building blocks of your scene. There are a lot of different
  13237. types of objects supported by POV-Ray: finite solid primitives, finite patch
  13238. primitives, infinite solid polynomial primitives and light sources.
  13239. Constructive Solid Geometry (CSG) is also supported.
  13240.  
  13241. The basic syntax of an object is a keyword describing its type, some floats,
  13242. vectors or other parameters which further define its location and/or shape
  13243. and some optional object modifiers such as texture, pigment, normal, finish,
  13244. bounding, clipping or transformations.
  13245.  
  13246. The texture describes what the object looks like, i. e. its material.
  13247. Textures are combinations of pigments, normals, finishes and halos. Pigment
  13248. is the color or pattern of colors inherent in the material. Normal is a
  13249. method of simulating various patterns of bumps, dents, ripples or waves by
  13250. modifying the surface normal vector. Finish describes the reflective and
  13251. refractive properties of a material. The halo is used to describe the
  13252. interior of the object.
  13253.  
  13254. Bounding shapes are finite, invisible shapes which wrap around complex, slow
  13255. rendering shapes in order to speed up rendering time. Clipping shapes are
  13256. used to cut away parts of shapes to expose a hollow interior. Transformations
  13257. tell the ray-tracer how to move, size or rotate the shape and/or the texture
  13258. in the scene.
  13259.  
  13260. 7.5.1            Empty and Solid Objects
  13261.  
  13262. It is very important that you know the basic concept behind empty and solid
  13263. objects in POV-Ray to fully understand how features like halos and
  13264. translucency are used.
  13265.  
  13266. Objects in POV-Ray can either be solid, empty or filled with (small)
  13267. particles.
  13268.  
  13269. A solid object is made from the material specified by its pigment and finish
  13270. statements (and to some degree its normal statement). By default all objects
  13271. are assumed to be solid. If you assign a stone texture to a sphere you'll get
  13272. a ball made completely of stone. It's like you had cut this ball from a block
  13273. of stone. A glass ball is a massive sphere made of glass.
  13274.  
  13275. You should be aware that solid objects are conceptual things. If you e. g.
  13276. clip away parts of the sphere you'll see that the sphere is empty, i. e.
  13277. you'll clearly see that the interior is empty and it just has a very thin
  13278. surface.
  13279.  
  13280. This is not contrary to the concept of a solid object used in POV-Ray. It is
  13281. assumed that all space inside the sphere is covered by the sphere's material.
  13282. Thus there is no room for any other particles like those used by fog or
  13283. halos.
  13284.  
  13285. Empty objects are created by adding the hollow keyword (see "Hollow") to the
  13286. object statement. An empty (or hollow) object is assumed to be made of a very
  13287. thin surface which is of the material specified by the pigment, finish and
  13288. normal statements. The object's interior is empty, i. e. it normally contains
  13289. air molecules.
  13290.  
  13291. An empty object can be filled with particles by adding fog or atmosphere to
  13292. the scene or by adding a halo to the object. It is very important to
  13293. understand that in order to fill an object with any kind of particles it
  13294. first has to be made hollow.
  13295.  
  13296. 7.5.1.1          Halo Pitfall
  13297.  
  13298. There is a pitfall in the current empty/solid object implementation that you
  13299. have to be aware of.
  13300.  
  13301. In order to be able to put solid objects inside a halo (this also holds for
  13302. fog and atmosphere) a test has to be made for every ray that passes through
  13303. the halo. If this ray travels through a solid object the halo will not be
  13304. calculated. This is what anyone will expect.
  13305.  
  13306. The problem arises when the camera ray is inside any non-hollow object. In
  13307. this case the ray is already traveling through a solid object and even if the
  13308. halo's container object is hit and it is hollow, the halo will not be
  13309. calculated. There is no way of telling between these two cases.
  13310.  
  13311. POV-Ray has to determine whether the camera is inside any object prior to
  13312. tracing a camera ray in order to be able to correctly render halos when the
  13313. camera is inside the container object. There's no way around doing this.
  13314.  
  13315. The solution to this problem (that will often happen with infinite objects
  13316. like planes) is to make those objects hollow too. Thus the ray will travel
  13317. through a hollow object, will hit the container object and the halo will be
  13318. calculated.
  13319.  
  13320.  
  13321. 7.5.1.2          Refraction Pitfall
  13322.  
  13323. There is a pitfall in the way refractive (and non-refractive translucent)
  13324. objects are handled.
  13325.  
  13326. Imagine you want to create an object that's partially made of glass and
  13327. stone. You'd use something like the following merge because you don't want to
  13328. see any inside surfaces.
  13329.  
  13330.   merge {
  13331.     sphere { <-1,0,0>, 2 texture { Stone } }
  13332.     sphere { <+1,0,0>, 2 texture { Glass } }
  13333.   }
  13334.  
  13335.  
  13336. What's wrong with this, you may ask? The problem is that there is no way of
  13337. telling what the interior of the actual object will look like. This is not a
  13338. problem of POV-Ray, it's a general problem. You can't define the interior of
  13339. any object in a surface based model. You would have to create some (complex)
  13340. rules to decide what the interior will look like. Is it made of stone? Is it
  13341. made of glass? Is it made of some bizarre mixture between glass and stone? Is
  13342. it half stone and half glass? Where is the boundary between the two materials
  13343. and what does it look like?
  13344.  
  13345. You will not be able to answer any of the above questions by just looking at
  13346. the above object. You need more information.
  13347.  
  13348. If you wanted to create an object made half of stone and half of glass you
  13349. would have used the following statements.
  13350.  
  13351.   union {
  13352.     intersection {
  13353.       sphere { <-1,0,0>, 2 }
  13354.       plane { x, 0 }
  13355.       texture { Stone }
  13356.     }
  13357.     intersection {
  13358.       sphere { <+1,0,0>, 2 }
  13359.       plane { x, 0 inverse }
  13360.       texture { Glass }
  13361.     }
  13362.   }
  13363.  
  13364.  
  13365. This example is correct because there is one object made only of stone and
  13366. one made only of glass.
  13367.  
  13368. You should never use objects whose interior is not well defined, i. e. there
  13369. must not be different textures for the object having different refractive
  13370. (and translucent) properties. You should be aware that this holds only for
  13371. the lowest layer if you use layered textures.
  13372.  
  13373.  
  13374. 7.5.2            Finite Solid Primitives
  13375.  
  13376. There are twelve different solid finite primitive shapes: blob, box, cone,
  13377. cylinder, fractal, height field, lathe, sphere, superellipsoid, surface of
  13378. revolution, text object and torus. These have a well-defined inside and can
  13379. be used in CSG (see section "Constructive Solid Geometry"). They are finite
  13380. and respond to automatic bounding. As with all shapes they can be translated,
  13381. rotated and scaled.
  13382.  
  13383. 7.5.2.1          Blob
  13384.  
  13385. Blobs are an interesting and flexible object type. Mathematically they are
  13386. iso-surfaces of scalar fields, i. e. their surface is defined by the strength
  13387. of the field in each point. If this strength is equal to a threshold value
  13388. you're on the surface otherwise you're not.
  13389.  
  13390. Picture each blob component as an object floating in space. This object is
  13391. filled with a field that has its maximum at the center of the object and
  13392. drops off to zero at the object's surface. The field strength of all those
  13393. components are added together to form the field of the blob. Now POV-Ray
  13394. looks for points where this field has a given value, the threshold value. All
  13395. these points form the surface of the blob object. Points with a greater field
  13396. value than the threshold value are considered to be inside while points with
  13397. a smaller field value are outside.
  13398.  
  13399. There's another, simpler way of looking at blobs. They can be seen as a union
  13400. of flexible components that attract or repel each other to form a blobby
  13401. organic looking shape. The components' surfaces actually stretch out smoothly
  13402. and connect as if they were made of honey or something like that.
  13403.  
  13404. A blob is made up of spherical and cylindrical components and is defined as
  13405. follows:
  13406.  
  13407.   blob {
  13408.     threshold THRESHOLD_VALUE
  13409.     cylinder { <END1>, <END2>, RADIUS, [ strength ] STRENGTH }
  13410.     sphere { <CENTER>, RADIUS, [ strength ] STRENGTH }
  13411.     [ component STRENGTH, RADIUS, <CENTER> ]
  13412.     [ hierarchy FLAG ]
  13413.     [ sturm ]
  13414.   }
  13415.  
  13416.  
  13417. The threshold keyword determines the total field strength value that POV-Ray
  13418. is looking for. By following the ray out into space and looking at how each
  13419. blob component affects the ray, POV-Ray will find the points in space where
  13420. the field strength is equal to the threshold value. The following list shows
  13421. some things you should know about the threshold value.
  13422.  
  13423.   2)A component disappears if the threshold value is greater than its
  13424.   3)As the threshold value gets larger the surface you see gets closer to the
  13425.   4)As the threshold value gets smaller, the surface you see gets closer to
  13426.     the surface of the components.
  13427.  
  13428.  
  13429. Cylindrical components are specified by the keyword cylinder giving a
  13430. cylinder formed by the base <END1>, the apex <END2> and the radius. The
  13431. cylinder has hemispherical caps at the base and apex. Spherical components
  13432. are specified by the keyword sphere forming a sphere at <CENTER> with the
  13433. given radius. Each component can be individually translated, rotated, scaled
  13434. and textured. The complete syntax for the cylindrical and spherical
  13435. components is:
  13436.  
  13437.   sphere { <CENTER>, RADIUS, [strength] STRENGTH
  13438.     [ translate <VECTOR> ]
  13439.     [ rotate <VECTOR> ]
  13440.     [ scale <VECTOR> ]
  13441.     TEXTURE_MODIFIERS
  13442.   }
  13443.  
  13444.   cylinder { <END1>, <END2>, RADIUS, [strength] STRENGTH
  13445.     [ translate <VECTOR> ]
  13446.     [ rotate <VECTOR> ]
  13447.     [ scale <VECTOR> ]
  13448.     TEXTURE_MODIFIERS
  13449.   }
  13450.  
  13451.  
  13452. By unevenly scaling a spherical component you can create ellipsoidal
  13453. components. The component keyword gives a spherical component and is only
  13454. used for compatibility with earlier POV-Ray versions.
  13455.  
  13456. The strength parameter is a float value specifying the field strength at the
  13457. center of the object. The strength may be positive or negative. A positive
  13458. value will make that component attract other components while a negative
  13459. value will make it repel other components. Components in different, separate
  13460. blob shapes do not affect each other.
  13461.  
  13462. You should keep the following things in mind.
  13463.  
  13464.   1)The strength value may be positive or negative. Zero is a bad value, as
  13465.     the net result is that no field was added --- you might just as well have
  13466.   2)If strength is positive, then POV-Ray will add the component's field to
  13467.     the space around the center of the component. If this adds enough field
  13468.   3)If the strength value is negative, then POV-Ray will subtract thesurface.
  13469.     component's field from the space around the center of the component. This
  13470.     will only do something if there happen to be positive components nearby.
  13471.     What happens is that the surface around any nearby positive components
  13472.     will be dented away from the center of the negative component.
  13473.  
  13474.  
  13475. The components of each blob object are internally bounded by a spherical
  13476. bounding hierarchy to speed up blob intersection tests and other operations.
  13477. By using the optional keyword hierarchy you can switch this hierarchy off.
  13478.  
  13479. An example of a three component blob is:
  13480.  
  13481.   blob {
  13482.     threshold 0.6
  13483.     sphere { <.75, 0, 0>, 1, 1 }
  13484.     sphere { <-.375, .64952, 0>, 1, 1 }
  13485.     sphere { <-.375, -.64952, 0>, 1, 1 }
  13486.     scale 2
  13487.   }
  13488.  
  13489.  
  13490. If you have a single blob component then the surface you see will just look
  13491. like the object used, i. e. a sphere or a cylinder, with the surface being
  13492. somewhere inside the surface specified for the component. The exact surface
  13493. location can be determined from the blob equation listed below (you will
  13494. probably never need to know this, blobs are more for visual appeal than for
  13495. exact modeling).
  13496.  
  13497. For the more mathematically minded, here's the formula used internally by
  13498. POV-Ray to create blobs. You don't need to understand this to use blobs. The
  13499. formula used for a single blob component is:
  13500.  
  13501.   density = strength * (1 - radius^2)^2
  13502.  
  13503.  
  13504. This formula has the nice property that it is exactly equal to the strength
  13505. parameter at the center of the component and drops off to exactly 0 at a
  13506. distance from the center of the component that is equal to the radius value.
  13507. The density formula for more than one blob component is just the sum of the
  13508. individual component densities:
  13509.  
  13510.  
  13511.   density = density1 + density2 + ...
  13512.  
  13513.  
  13514. The calculations for blobs must be very accurate. If this shape renders
  13515. improperly you may add the keyword sturm after the last component to use
  13516. POV-Ray's slower-yet-more-accurate Sturmian root solver.
  13517.  
  13518. 7.5.2.2          Box
  13519.  
  13520. A simple box can be defined by listing two corners of the box like this:
  13521.  
  13522.   box { <CORNER1>, <CORNER2> }
  13523.  
  13524.  
  13525. The geometry of a box.
  13526.  
  13527. Where <CORNER1> and <CORNER2> are vectors defining the x, y, z coordinates of
  13528. the opposite corners of the box.
  13529.  
  13530. Note that all boxes are defined with their faces parallel to the coordinate
  13531. axes. They may later be rotated to any orientation using the rotate keyword.
  13532.  
  13533. Each element of <CORNER1> should always be less than the corresponding
  13534. element in <CORNER2>. If any elements of <CORNER1> are larger than <CORNER2>
  13535. the box will not appear in the scene.
  13536.  
  13537. Boxes are calculated efficiently and make good bounding shapes (if manually
  13538. bounding seems to be necessary).
  13539.  
  13540. 7.5.2.3          Cone
  13541.  
  13542. A finite length cone or a frustum (a cone with the point cut off) may be
  13543. defined by.
  13544.  
  13545.   cone {
  13546.     <BASE_POINT>, BASE_RADIUS, <CAP_POINT>, CAP_RADIUS
  13547.     [ open ]
  13548.   }
  13549.  
  13550.  
  13551. The geometry of a cone.
  13552.  
  13553. Where <BASE_POINT> and < CAP_POINT> are vectors defining the x, y, z
  13554. coordinates of the center of the cone's base and cap and BASE_RADIUS and
  13555. CAP_RADIUS are float values for the corresponding radii.
  13556.  
  13557. Normally the ends of a cone are closed by flat planes which are parallel to
  13558. each other and perpendicular to the length of the cone. Adding the optional
  13559. keyword open after CAP_RADIUS will remove the end caps and results in a
  13560. tapered hollow tube like a megaphone or funnel.
  13561.  
  13562. 7.5.2.4          Cylinder
  13563.  
  13564. A finite length cylinder with parallel end caps may be defined by.
  13565.  
  13566.   cylinder {
  13567.     <BASE_POINT>, <CAP_POINT>, RADIUS
  13568.     [ open ]
  13569.   }
  13570.  
  13571.  
  13572. The geometry of a cylinder.
  13573.  
  13574. Where <BASE_POINT> and < CAP_POINT> are vectors defining the x, y, z
  13575. coordinates of the cylinder's base and cap and RADIUS is a float value for
  13576. the radius.
  13577.  
  13578. Normally the ends of a cylinder are closed by flat planes which are parallel
  13579. to each other and perpendicular to the length of the cylinder. Adding the
  13580. optional keyword open after the radius will remove the end caps and results
  13581. in a hollow tube.
  13582.  
  13583. 7.5.2.5          Height Field
  13584.  
  13585. Height fields are fast, efficient objects that are generally used to create
  13586. mountains or other raised surfaces out of hundreds of triangles in a mesh.
  13587. The height field syntax is:
  13588.  
  13589.   height_field {
  13590.     FILE_TYPE "FILENAME"
  13591.     [ hierarchy BOOL ]
  13592.     [ smooth BOOL ]
  13593.     [ water_level FLOAT ]
  13594.   }
  13595.  
  13596.  
  13597. A height field is essentially a one unit wide by one unit long square with a
  13598. mountainous surface on top. The height of the mountain at each point is taken
  13599. from the color number or palette index of the pixels in a graphic image file.
  13600. The maximum height is one, which corresponds to the maximum possible color or
  13601. palette index value in the image file.
  13602.  
  13603.         ________  <---- image index 255 (or 65535 for 16-bit images)
  13604.       /        /|
  13605. +1y  ---------- |
  13606.      |        | |
  13607.      |        | |+1z <- Image upper-right
  13608.      |        | /
  13609. 0,0,0---------- +1x
  13610.      ^
  13611.      |____ Image lower-left
  13612. The size and orientation of an un-scaled height field.
  13613.  
  13614. The mesh of triangles corresponds directly to the pixels in the image file.
  13615. Each square formed by four neighboring pixels is divided into two triangles.
  13616. An image with a resolution of N*M pixels has (N-1)*(M-1) squares that are
  13617. divided into 2*(N-1)*(M-1) triangles.
  13618.  
  13619. Four pixels of an image and the resulting heights and triangles in the height
  13620. field.
  13621.  
  13622. The resolution of the height field is influenced by two factors: the
  13623. resolution of the image and the resolution of the color/index values. The
  13624. size of the image determines the resolution in the x- and z-direction. A
  13625. larger image uses more triangles and looks smoother. The resolution of the
  13626. color/index value determines the resolution along the y-axis. A height field
  13627. made from an 8 bit image can have 256 different height levels while one made
  13628. from a 16 bit image can have up to 65536 different height levels. Thus the
  13629. second height field will look much smoother in the y-direction if the height
  13630. field is created appropriately.
  13631.  
  13632. The size/resolution of the image does not affect the size of the height
  13633. field. The un-scaled height field size will always be 1* 1. Higher resolution
  13634. image files will create smaller triangles, not larger height fields.
  13635.  
  13636. There are six or possibly seven types of files which can define a
  13637. heightfield, as follows:
  13638.  
  13639.   height_field { gif "filename.gif" }
  13640.   height_field { pgm "filename.pgm" }
  13641.   height_field { png "filename.png" }
  13642.   height_field { pot "filename.pot" }
  13643.   height_field { ppm "filename.ppm" }
  13644.   height_field { sys "filename.???" }
  13645.   height_field { tga "filename.tga" }
  13646.  
  13647.  
  13648. The image file used to create a height field can be a GIF, TGA, POT, PNG,
  13649. PGM, PPM and possibly a system specific (e. g. Windows BMP or Macintosh Pict)
  13650. format file. The GIF, PNG, PGM and possibly system format files are the only
  13651. ones that can be created using a standard paint program. Though there are
  13652. paint programs for creating TGA image files they won't be of much use for
  13653. creating the special 16 bit TGA files used by POV-Ray (see below and
  13654. "HF_Gray_16" for more details).
  13655.  
  13656. In an image file like GIF that uses a color palette the color number is the
  13657. palette index at a given pixel. Use a paint program to look at the palette of
  13658. a GIF image. The first color is palette index zero, the second is index one,
  13659. the third is index two and so on. The last palette entry is index 255.
  13660. Portions of the image that use low palette entries will result in lower parts
  13661. of the height field. Portions of the image that use higher palette entries
  13662. will result in higher parts of the height field.
  13663.  
  13664. Height fields created from GIF files can only have 256 different height
  13665. levels because the maximum number of colors in a GIF file is 256.
  13666.  
  13667. The color of the palette entry does not affect the height of the pixel. Color
  13668. entry 0 could be red, blue, black or orange but the height of any pixel that
  13669. uses color entry 0 will always be 0. Color entry 255 could be indigo, hot
  13670. pink, white or sky blue but the height of any pixel that uses color entry 255
  13671. will always be 1.
  13672.  
  13673. You can create height field GIF images with a paint program or a fractal
  13674. program like Fractint. You can usually get Fractint from most of the same
  13675. sources as POV-Ray.
  13676.  
  13677. A POT file is essentially a GIF file with a 16 bit palette. The maximum
  13678. number of colors in a POT file is 65536. This means a POT height field can
  13679. have up to 65536 possible height values. This makes it possible to have much
  13680. smoother height fields. Note that the maximum height of the field is still 1
  13681. even though more intermediate values are possible.
  13682.  
  13683. At the time of this writing the only program that created POT files was a
  13684. freeware IBM-PC program called Fractint. POT files generated with this
  13685. fractal program create fantastic landscapes.
  13686.  
  13687. The TGA and PPM file formats may be used as a storage device for 16 bit
  13688. numbers rather than an image file. These formats use the red and green bytes
  13689. of each pixel to store the high and low bytes of a height value. These files
  13690. are as smooth as POT files but they must be generated with special
  13691. custom-made programs. Several programs can create TGA heightfields in the
  13692. format POV uses, such as gforge and Terrain Maker.
  13693.  
  13694. PNG format heightfields are usually stored in the form of a grayscale image
  13695. with black corresponding to lower and white to higher parts of the height
  13696. field. Because PNG files can store up to 16 bits in grayscale images they
  13697. will be as smooth as TGA and PPM images. Since they are grayscale images you
  13698. will be able to view them with a regular image viewer. gforge can create
  13699. 16-bit heightfields in PNG format. Color PNG images will be used in the same
  13700. way as TGA and PPM images.
  13701.  
  13702. SYS format is a platform specific file format. See your platform specific
  13703. documentation for details.
  13704.  
  13705. An optional water_level parameter may be added after the file name. It
  13706. consists of the keyword water_level followed by a float value telling the
  13707. program to ignore parts of the height field below that value. The default
  13708. value is zero and legal values are between zero and one. For example
  13709. water_level .5 tells POV-Ray to only render the top half of the height field.
  13710. The
  13711. other half is below the water and couldn't be seen anyway. This term comes
  13712. from the popular use of height fields to render landscapes. A height field
  13713. would be used to create islands and another shape would be used to simulate
  13714. water around the islands. A large portion of the height field would be
  13715. obscured by the water so the water_level parameter was introduced to allow
  13716. the ray-tracer to ignore the unseen parts of the height field. water_level is
  13717. also used to cut away unwanted lower values in a height field. For example if
  13718. you have an image of a fractal on a solid colored background, where the
  13719. background color is palette entry 0, you can remove the background in the
  13720. height field by specifying, water_level .001.
  13721.  
  13722. Normally height fields have a rough, jagged look because they are made of
  13723. lots of flat triangles. Adding the keyword smooth causes POV-Ray to modify
  13724. the surface normal vectors of the triangles in such a way that the lighting
  13725. and shading of the triangles will give a smooth look. This may allow you to
  13726. use a lower resolution file for your height field than would otherwise be
  13727. needed. However, smooth triangles will take longer to render.
  13728.  
  13729. In order to speed up the intersection tests an one-level bounding hierarchy
  13730. is available. By default it is always used but it can be switched off to
  13731. eventually improve the rendering speed for small height fields (i. e. low
  13732. resolution images).
  13733.  
  13734. 7.5.2.6          Julia Fractal
  13735.  
  13736. A julia fractal object is a 3-D slice of a 4-D object created by generalizing
  13737. the process used to create the classic Julia sets. You can make a wide
  13738. variety of strange objects using julia_fractal, including some that look like
  13739. bizarre blobs of twisted taffy.
  13740.  
  13741. The julia_fractal syntax (with default values listed in comments) is:
  13742.  
  13743.   julia_fractal {
  13744.     4DJULIA_PARAMETER                 // default is <1,0,0,0>
  13745.     [ quaternion | hypercomplex ]     // default is quaternion
  13746.     [ sqr | cube | exp |
  13747.       reciprocal | sin | asin |
  13748.       sinh | asinh | cos | acos |
  13749.       cosh | acosh | tan | atan |
  13750.       tanh | atanh | log | pwr(X,Y) ] // default is sqr
  13751.     [ max_iteration MAX_ITERATION ]   // default value 20
  13752.     [ precision PRECISION ]           // default value 20
  13753.     [ slice 4DNORMAL, DISTANCE ]      // default <0,0,0,1>,0
  13754.   }
  13755.  
  13756.  
  13757. The 4-D vector 4DJULIA_PARAMETER is the classic Julia parameter p in the
  13758. iterated formula f(h) + p.
  13759.  
  13760. The julia fractal object is calculated by using an algorithm that determines
  13761. whether an arbitrary point h(0) in 4-D space is inside or outside the object.
  13762. The algorithm requires generating the sequence of vectors h(0), h(1), ... by
  13763. iterating the formula
  13764.  
  13765.   h(n+1) = f(h(n)) + p (n = 0, 1, ..., max_iteration-1)
  13766.  
  13767.  
  13768. where p is the fixed 4-D vector parameter of the julia fractal and f() is one
  13769. of the functions sqr, cube, ... specified by the presence of the
  13770. corresponding keyword. The point h(0) that begins the sequence is considered
  13771. inside the julia fractal object if none of the vectors in the sequence
  13772. escapes a hypersphere of radius 4 about the origin before the iteration
  13773. number reaches the max_iteration value. As you increase max_iteration, some
  13774. points escape that did not previously escape, forming the julia fractal.
  13775. Depending on the JULIA_PARAMETER, the julia fractal object is not necessarily
  13776. connected; it may be scattered fractal dust. Using a low max_iteration can
  13777. fuse together the dust to make a solid object. A high max_iteration is more
  13778. accurate but slows rendering. Even though it is not accurate, the solid
  13779. shapes you get with a low_maximum iteration value can be quite interesting.
  13780.  
  13781. Since the mathematical object described by this algorithm is four-dimensional
  13782. and POV-Ray renders three dimensional objects, there must be a way to reduce
  13783. the number of dimensions of the object from four dimensions to three. This is
  13784. accomplished by intersecting the 4-D fractal with a 3-D plane defined by the
  13785. slice field and then projecting the intersection to 3-D space. The slice
  13786. plane is the 3-D space that is perpendicular to NORMAL4D and is DISTANCE
  13787. units from the origin. Zero length NORMAL4D vectors or a NORMAL4D vector with
  13788. a zero fourth component are illegal.
  13789.  
  13790. You can get a good feel for the four dimensional nature of a julia fractal by
  13791. using POV-Ray's animation feature to vary a slice's DISTANCE parameter. You
  13792. can make the julia fractal appear from nothing, grow, then shrink to nothing
  13793. as DISTANCE changes, much as the cross section of a 3-D object changes as it
  13794. passes through a plane.
  13795.  
  13796. The precision parameter is a tolerance used in the determination of whether
  13797. points are inside or outside the fractal object. Larger values give more
  13798. accurate results but slower rendering. Use as low a value as you can without
  13799. visibly degrading the fractal object's appearance.
  13800.  
  13801. The presence of the keywords quaternion or hypercomplex determine which 4-D
  13802. algebra is used to calculate the fractal. Both are 4-D generalizations of the
  13803. complex numbers but neither satisfies all the field properties (all the
  13804. properties of real and complex numbers that many of us slept through in high
  13805. school). Quaternions have non-commutative multiplication and hypercomplex
  13806. numbers can fail to have a multiplicative inverse for some non-zero elements
  13807. (it has been proved that you cannot successfully generalize complex numbers
  13808. to four dimensions with all the field properties intact, so something has to
  13809. break). Both of these algebras were discovered in the 19th century. Of the
  13810. two, the quaternions are much better known, but one can argue that
  13811. hypercomplex numbers are more useful for our purposes, since complex valued
  13812. functions such as sin, cos, etc. can be generalized to work for hypercomplex
  13813. numbers in a uniform way.
  13814.  
  13815. For the mathematically curious, the algebraic properties of these two
  13816. algebras can be derived from the multiplication properties of the unit basis
  13817. vectors 1 = <1,0,0,0>, i=< 0,1,0,0>, j=<0,0,1,0> and k=< 0,0,0,1>. In both
  13818. algebras 1 x = x 1 = x for any x (1 is the multiplicative identity). The
  13819. basis vectors 1 and i behave exactly like the familiar complex numbers 1 and
  13820. i in both algebras.
  13821.  
  13822. Quaternion basis vector multiplication rules:
  13823.  
  13824.   ij = k;            jk  = i;   ki = j
  13825.   ji = -k;           kj  = -i;  ik = -j
  13826.   ii = jj = kk = -1; ijk = -1;
  13827.  
  13828.  
  13829. Hypercomplex basis vector multiplication rules:
  13830.  
  13831.   ij = k;            jk = -i;   ki = -j
  13832.   ji = k;            kj = -i;   ik = -j
  13833.   ii = jj = kk = -1; ijk = 1;
  13834.  
  13835.  
  13836. A distance estimation calculation is used with the quaternion calculations to
  13837. speed them up. The proof that this distance estimation formula works does not
  13838. generalize from two to four dimensions but the formula seems to work well
  13839. anyway, the absence of proof notwithstanding!
  13840.  
  13841. The presence of one of the function keywords sqr, cube, etc. determines which
  13842. function is used for f(h) in the iteration formula h(n+1) = f(h(n)) + p. Most
  13843. of the function keywords work only if the hypercomplex keyword is present.
  13844. Only sqr and cube work with quaternions. The functions are all familiar
  13845. complex functions generalized to four dimensions.
  13846.  
  13847.   Function Keyword    Maps 4-D value h to:
  13848. ================================================
  13849.   sqr                 h*h
  13850.   cube                h*h*h
  13851.   exp                 e raised to the power h
  13852.   reciprocal          1/h
  13853.   sin                 sine of h
  13854.   asin                arcsine of h
  13855.   sinh                hyperbolic sine of h
  13856.   asinh               inverse hyperbolic sine of h
  13857.   cos                 cosine of h
  13858.   acos                arccosine of h
  13859.   cosh                hyperbolic cos of h
  13860.   acosh               inverse hyperbolic cosine of h
  13861.  
  13862.   tan                 tangent of h
  13863.   atan                arctangent of h
  13864.   tanh                hyperbolic tangent of h
  13865.   atanh               inverse hyperbolic tangent of h
  13866.   log                 natural logarithm of h
  13867.   pwr(x,y)            h raised to the complex power x+iy
  13868.  
  13869.  
  13870. A simple example of a julia fractal object is:
  13871.  
  13872.   julia_fractal {
  13873.     <-0.083,0.0,-0.83,-0.025>
  13874.     quaternion
  13875.     sqr
  13876.     max_iteration 8
  13877.     precision 15
  13878.   }
  13879.  
  13880.  
  13881. The first renderings of julia fractals using quaternions were done by Alan
  13882. Norton and later by John Hart in the '80's. This new POV-Ray implementation
  13883. follows Fractint in pushing beyond what is known in the literature by using
  13884. hypercomplex numbers and by generalizing the iterating formula to use a
  13885. variety of transcendental functions instead of just the classic Mandelbrot
  13886. z^2 + c formula. With an extra two dimensions and eighteen functions to work
  13887. with, intrepid explorers should be able to locate some new fractal beasties
  13888. in hyperspace, so have at it!
  13889.  
  13890. 7.5.2.7          Lathe
  13891.  
  13892. The lathe is an object generated from rotating a two-dimensional curve about
  13893. an axis. This curve is defined by a set of points which are connected by
  13894. linear, quadratic or cubic spline curves. The syntax is:
  13895.  
  13896.   lathe {
  13897.     [ linear_spline | quadratic_spline | cubic_spline ]
  13898.     NUMBER_OF_POINTS,
  13899.     <POINT_1>, <POINT_2>, ..., <POINT_n>
  13900.     [ sturm ]
  13901.   }
  13902.  
  13903.  
  13904. The parameter NUMBER_OF_POINTS determines how many two-dimensional points are
  13905. forming the curve. These points are connected by linear, quadratic or cubic
  13906. splines as specified by an optional keyword (the default is linear_spline).
  13907. Since the curve is not automatically closed, i. e. the first and last points
  13908. are not automatically connected, you'll have to do this by your own if you
  13909. want a closed curve. The curve thus defined is rotated about the y-axis to
  13910. form the lathe object which is centered at the origin.
  13911.  
  13912. The following examples creates a simple lathe object that looks like a thick
  13913. cylinder, i. e. a cylinder with a thick wall:
  13914.  
  13915.   lathe {
  13916.     linear_spline
  13917.     5,
  13918.     <2, 0>, <3, 0>, <3, 5>, <2, 5>, <2, 0>
  13919.     pigment {Red}
  13920.   }
  13921.  
  13922.  
  13923. The cylinder has an inner radius of 2 and an outer radius of 3, giving a wall
  13924. width of 1. It's height is 5 and it's located at the origin pointing up, i.
  13925. e. the rotation axis is the y-axis. Note that the first and last point are
  13926. equal to get a closed curve.
  13927.  
  13928. The splines that are used by the lathe and prism objects are a little bit
  13929. difficult to understand. The basic concept of splines is to draw a curve
  13930. through a given set of points in a determined way. The linear spline is the
  13931. simplest spline because it's nothing more than connecting consecutive points
  13932. with a line. This means that the curve that is drawn between two points only
  13933. depends on those two points. No additional information is taken into account.
  13934. Quadratic and cubic splines are different in that they do not only take other
  13935. points into account when connecting two points but they also look smoother
  13936. and - in the case of the cubic spline - produce smoother transitions at each
  13937. point.
  13938.  
  13939. Quadratic splines are made of quadratic curves. Each of them connects two
  13940. consecutive points. Since those two points (call them second and third point)
  13941. are not sufficient to describe a quadratic curve the predecessor of the
  13942. second point is taken into account when the curve is drawn. Mathematically
  13943. the relationship (their location on the 2-D plane) between the first and
  13944. second point determines the slope of the curve at the second point. The slope
  13945. of the curve at the third point is out of control. Thus quadratic splines
  13946. look much smoother than linear splines but the transitions at each point are
  13947. generally not smooth because the slopes on both sides of the point are
  13948. different.
  13949.  
  13950. Cubic splines overcome the transition problem of quadratic splines because
  13951. they also take the fourth point into account when drawing the curve between
  13952. the second and third point. The slope at the fourth point is under control
  13953. now and allows a smooth transition at each point. Thus cubic splines produce
  13954. the most flexible and smooth curves.
  13955.  
  13956. You should note that the number of spline segments, i. e. curves between two
  13957. points, depends on the spline type used. For linear splines you get n-1
  13958. segments connecting the points P[i], i=1,...,n. A quadratic spline gives you
  13959. n-2 segments because the last point is only used for determining the slope as
  13960. explained above (thus you'll need at least three points to define a quadratic
  13961. spline). The same holds for cubic splines where you get n-3 segments with the
  13962. first and last point used only for slope calculations (thus needing at least
  13963. four points).
  13964.  
  13965. If you want to get a closed quadratic and cubic spline with smooth
  13966. transitions at the end points you have to make sure that in the cubic case
  13967. P[n-1] = P[2] (to get a closed curve), P[n] = P[3] and P[n-2] = P[1] (to
  13968. smooth the transition). In the quadratic case P[n-1] = P[1] (to close the
  13969. curve) and P[n] = P[2].
  13970.  
  13971. The slower but more accurate Sturmian root solver may be used with the
  13972. quadratic spline lathe if the shape does not render properly. Since a
  13973. quadratic polynomial has to be solved for the linear spline lathe the
  13974. Sturmian root solver is not needed. In case of cubic splines the Sturmian
  13975. root solver is always used because a 6th order polynomial has to be solved.
  13976.  
  13977. 7.5.2.8          Prism
  13978.  
  13979. The prism is an object generated from sweeping one or more two-dimensional,
  13980. closed curves along an axis. These curves are defined by a set of points
  13981. which are connected by linear, quadratic or cubic splines.
  13982.  
  13983. The syntax for the prism is:
  13984.  
  13985.   prism {
  13986.     [ linear_sweep | conic_sweep ]
  13987.     [ linear_spline | quadratic_spline | cubic_spline ]
  13988.     HEIGHT1,
  13989.     HEIGHT2,
  13990.     TOTAL_NUMBER_OF_POINTS,
  13991.     <POINT_1>, <POINT_2>, ..., <POINT_n>
  13992.     [ open ]
  13993.     [ sturm ]
  13994.   }
  13995.  
  13996.  
  13997. The prism object allows you to use any number of sub-prisms inside one prism
  13998. statement (they are of the same spline and sweep type). Wherever an even
  13999. number of sub-prisms overlaps a hole appears.
  14000.  
  14001. The syntax of the prism object depends on the type of spline curve used.
  14002. Below the syntax of the linear spline prism is given.
  14003.  
  14004.   prism {
  14005.     linear_spline
  14006.     HEIGHT1,
  14007.     HEIGHT2,
  14008.     TOTAL_NUMBER_OF_POINTS,
  14009.     <A_1>, <A_2>, ..., <A_na>, <A_1>,
  14010.     <B_1>, <B_2>, ..., <B_nb>, <B_1>,
  14011.     <C_1>, <C_2>, ..., <C_nc>, <C_1>,
  14012.     ...
  14013.   }
  14014.  
  14015.  
  14016. Each of the sub-prisms has to be closed by repeating the first point of a
  14017. sub-prism at the end of the sub-prism's point sequence. If this is not the
  14018. case a warning is issued and the prism is ignored (with linear splines
  14019. automatic closing is used). This implies that all points of a prism are
  14020. different (except the first and last of course). This applies to all spline
  14021. types though the control points of the quadratic and cubic splines can be
  14022. arbitrarily chosen.
  14023.  
  14024. The last sub-prism of a linear spline prism is automatically closed - just
  14025. like the last sub-polygon in the polygon statement - if the first and last
  14026. point of the sub-polygon's point sequence are not the same. This make it very
  14027. easy to convert between polygons and prisms. Quadratic and cubic splines are
  14028. never automatically closed.
  14029.  
  14030. The syntax for quadratic spline prisms is:
  14031.  
  14032.   prism {
  14033.     quadratic_spline
  14034.     HEIGHT1,
  14035.     HEIGHT2,
  14036.     TOTAL_NUMBER_OF_POINTS,
  14037.     <CL_A>, <A_1>, <A_2>, ..., <A_na>, <A_1>,
  14038.     <CL_B>, <B_1>, <B_2>, ..., <B_nb>, <B_1>,
  14039.     <CL_C>, <C_1>, <C_2>, ..., <C_nc>, <C_1>,
  14040.     ...
  14041.   }
  14042.  
  14043.  
  14044. Quadratic spline sub-prisms need an additional control point at the beginning
  14045. of each sub-prisms' point sequence to determine the slope at the start of the
  14046. curve.
  14047.  
  14048. Last but not least the syntax for the cubic spline prism.
  14049.  
  14050.   prism {
  14051.     cubic_spline
  14052.     HEIGHT1,
  14053.     HEIGHT2,
  14054.     TOTAL_NUMBER_OF_POINTS,
  14055.     <CL_A1>, <A_1>, <A_2>, ..., <A_na>, <A_1>, <CL_A2>,
  14056.     <CL_B1>, <B_1>, <B_2>, ..., <B_nb>, <B_1>, <CL_B2>,
  14057.     <CL_C1>, <C_1>, <C_2>, ..., <C_nc>, <C_1>, <CL_C2>,
  14058.     ...
  14059.   }
  14060.  
  14061.  
  14062. In addition to the closed point sequence each cubic spline sub-prism needs
  14063. two control points to determine the slopes at the start and end of the curve.
  14064.  
  14065.  
  14066. The parameter TOTAL_NUMBER_OF_POINTS determines how many two-dimensional
  14067. points (lying in the x-z-plane) form the curves (this includes all control
  14068. points needed for quadratic and cubic splines). The curves are swept along
  14069. the y-axis from HEIGHT1 to HEIGHT2 to form the prism object. By default
  14070. linear sweeping is used to create the prism, i. e. the prism's walls are
  14071. perpendicular to the x-z-plane (the size of the curve does not change during
  14072. the sweep). You can also use conic sweeping (conic_sweep) that leads to a
  14073. prism with cone-like walls by scaling the curve down during the sweep.
  14074.  
  14075. Like cylinders the prism is normally closed. You can remove the caps on the
  14076. prism by using the open keyword. If you do so you shouldn't use it with CSG
  14077. because the results may get wrong.
  14078.  
  14079. The following example creates a simple prism object that looks like a piece
  14080. of cake:
  14081.  
  14082.   prism {
  14083.     linear_sweep
  14084.     linear_spline
  14085.     0, 1,
  14086.     4,
  14087.     <-1, 0>, <1, 0>, <0, 5>, <-1, 0>
  14088.     pigment {Red}
  14089.   }
  14090.  
  14091.  
  14092. For an explanation of the spline concept read the description of the lathe
  14093. object.
  14094.  
  14095. The slower but more accurate Sturmian root solver may be used with the cubic
  14096. spline prisms if the shape does not render properly. The linear and quadratic
  14097. spline prisms do not need the Sturmian root solver.
  14098.  
  14099. 7.5.2.9          Sphere
  14100.  
  14101. The syntax of the sphere object is:
  14102.  
  14103.   sphere {
  14104.     <CENTER>, RADIUS
  14105.   }
  14106.  
  14107.  
  14108. The geometry of a sphere.
  14109.  
  14110. Where <CENTER> is a vector specifying the x, y, z coordinates of the center
  14111. of the sphere and RADIUS is a float value specifying the radius. Spheres may
  14112. be scaled unevenly giving an ellipsoid shape.
  14113.  
  14114. Because spheres are highly optimized they make good bounding shapes (if
  14115. manual bounding seems to be necessary).
  14116.  
  14117. 7.5.2.10         Superquadric Ellipsoid
  14118.  
  14119. The superquadric ellipsoid is an extension of the quadric ellipsoid. It can
  14120. be used to create boxes and cylinders with round edges and other interesting
  14121. shapes. Mathematically it is given by the equation:
  14122.  
  14123.   f(x, y, z) = (|x|^(2/e) + |y|^(2/e)) ^ (e/n) + |z|^(2/n) - 1 = 0
  14124.  
  14125.  
  14126. The values of e and n, called the east-west and north-south exponent,
  14127. determine the shape of the superquadric ellipsoid. Both have to be greater
  14128. than zero. The sphere is e. g. given by e = 1 and n = 1.
  14129.  
  14130. The syntax of the superquadric ellipsoid, which is located at the origin, is:
  14131.  
  14132.  
  14133.   superellipsoid { <e, n> }
  14134.  
  14135.  
  14136. Two useful objects are the rounded box and the rounded cylinder. These are
  14137. declared in the following way.
  14138.  
  14139.   #declare Rounded_Box = superellipsoid { <r, r> }
  14140.   #declare Rounded_Cylinder = superellipsoid { <1, r> }
  14141.  
  14142.  
  14143. The roundedness r determines the roundedness of the edges and has to be
  14144. greater than zero and smaller than one. The smaller you choose the values of
  14145. r the smaller and sharper the edges will get.
  14146.  
  14147. Very small values of e and n might cause problems with the root solver (the
  14148. Sturmian root solver cannot be used).
  14149.  
  14150. 7.5.2.11         Surface of Revolution
  14151.  
  14152. The surface of revolution (SOR) object is generated by rotating the graph of
  14153. a function about an axis. This function describes the dependence of the
  14154. radius from the position on the rotation axis. The syntax of the SOR object
  14155. is:
  14156.  
  14157.   sor {
  14158.     NUMBER_OF_POINTS,
  14159.     <POINT0>, <POINT1>, ..., <POINTn-1>
  14160.     [ open ]
  14161.     [ sturm ]
  14162.   }
  14163.  
  14164.  
  14165. The points <POINT0> through <POINTn-1> are two-dimensional vectors consisting
  14166. of the radius and the corresponding height, i. e. the position on the
  14167. rotation axis. These points are smoothly connected (the curve is passing
  14168. through the specified points) and rotated about the y-axis to form the SOR
  14169. object. The first and last points are only used to determine the slopes of
  14170. the function at the start and end point. The function used for the SOR object
  14171. is similar to the splines used for the lathe object. The difference is that
  14172. the SOR object is less flexible because it underlies the restrictions of any
  14173. mathematical function, i. e. to any given point y on the rotation axis
  14174. belongs at most one function value, i. e. one radius value. You can't rotate
  14175. closed curves with the SOR object.
  14176.  
  14177. The optional keyword open allows you to remove the caps on the SOR object. If
  14178. you do this you shouldn't use it with CSG anymore because the results may be
  14179. wrong.
  14180.  
  14181. The SOR object is useful for creating bottles, vases, and things like that. A
  14182. simple vase could look like this:
  14183.  
  14184.   #declare Vase = sor {
  14185.     7,
  14186.     <0.000000, 0.000000>
  14187.     <0.118143, 0.000000>
  14188.     <0.620253, 0.540084>
  14189.     <0.210970, 0.827004>
  14190.     <0.194093, 0.962025>
  14191.     <0.286920, 1.000000>
  14192.     <0.468354, 1.033755>
  14193.     open
  14194.   }
  14195.  
  14196.  
  14197. One might ask why there is any need for a SOR object if there is already a
  14198. lathe object which is much more flexible. The reason is quite simple. The
  14199. intersection test with a SOR object involves solving a cubic polynomial while
  14200. the test with a lathe object requires to solve of a 6th order polynomial (you
  14201. need a cubic spline for the same smoothness). Since most SOR and lathe
  14202. objects will have several segments this will make a great difference in
  14203. speed. The roots of the 3rd order polynomial will also be more accurate and
  14204. easier to find.
  14205.  
  14206. The slower but more accurate Sturmian root solver may be used with the
  14207. surface of revolution object if the shape does not render properly.
  14208.  
  14209. The following explanations are for the mathematically interested reader who
  14210. wants to know how the surface of revolution is calculated. Though it is not
  14211. necessary to read on it might help in understanding the SOR object.
  14212.  
  14213. The function that is rotated about the y-axis to get the final SOR object is
  14214. given by
  14215.  
  14216.   r^2 = f(h) = A*h^3 + B*h^2 + C*h + D
  14217.  
  14218.  
  14219. with radius r and height h. Since this is a cubic function in h it has enough
  14220. flexibility to allow smooth curves.
  14221.  
  14222. The curve itself is defined by a set of n points P(i), i=0...n-1, which are
  14223. interpolated using one function for every segment of the curve. A segment j,
  14224. j=1...n-3, goes from point P(j) to point P(j+1) and uses points P(j-1) and
  14225. P(j+2) to determine the slopes at the endpoints. If there are n points we
  14226. will have n-3 segments. This means that we need at least four points to get a
  14227. proper curve.
  14228.  
  14229. The coefficients A(j), B(j), C(j) and D(j) are calculated for every segment
  14230. using the equation
  14231.  
  14232.   b = M * x, with
  14233.  
  14234.       /                                        \
  14235.       | r(j)^2                                 |
  14236.       |                                        |
  14237.       | r(j+1)^2                               |
  14238.   b = |                                        |
  14239.       | 2*r(j)*(r(j+1)-r(j-1))/(h(j+1)-h(j-1)) |
  14240.       |                                        |
  14241.       | 2*r(j+1)*(r(j+2)-r(j))/(h(j+2)-h(j))   |
  14242.                                               /
  14243.  
  14244.       /                                 \
  14245.       |   h(j)^3    h(j)^2    h(j)    1 |
  14246.       |                                 |
  14247.       |   h(j+1)^3  h(j+1)^2  h(j+1)  1 |
  14248.   M = |                                 |
  14249.       | 3*h(j)^2    2*h(j)    1       0 |
  14250.       |                                 |
  14251.       | 3*h(j+1)^2  2*h(j+1)  1       0 |
  14252.                                        /
  14253.  
  14254.       /      \
  14255.       | A(j) |
  14256.       |      |
  14257.       | B(j) |
  14258.   x = |      |
  14259.       | C(j) |
  14260.       |      |
  14261.       | D(j) |
  14262.             /
  14263.  
  14264.  
  14265. where r(j) is the radius and h(j) is the height of point P(j).
  14266.  
  14267. The figure below shows the configuration of the points P(i), the location of
  14268. segment j, and the curve that is defined by this segment.
  14269.  
  14270. Segment j of n-3 segments in a point configuration of n points. The points
  14271. describe the curve of a surface of revolution.
  14272.  
  14273. 7.5.2.12         Text
  14274.  
  14275. A text object creates 3-D text as an extruded block letter. Currently only
  14276. TrueType fonts are supported but the syntax allows for other font types to be
  14277. added in the future. The syntax is:
  14278.  
  14279.   text {
  14280.     ttf "FONTNAME.TTF",
  14281.     "STRING_OF_TEXT",
  14282.     THICKNESS_FLOAT, OFFSET_VECTOR
  14283.   }
  14284.  
  14285.  
  14286. Where fontname.ttf is the name of the TrueType font file. It is a quoted
  14287. string literal or string expression. The string expression which follows is
  14288. the actual text of the string object. It too may be a quoted string literal
  14289. or string expression. See section "Strings" for more on string expressions.
  14290.  
  14291. The text will start with the origin at the lower left, front of the first
  14292. character and will extend in the +x-direction. The baseline of the text
  14293. follows the x-axis and decenders drop into the -y-direction. The front of the
  14294. character sits in the x-y-plane and the text is extruded in the +z-direction.
  14295. The front-to-back thickness is specified by the required value
  14296. THICKNESS_FLOAT.
  14297.  
  14298. Characters are generally sized so that 1 unit of vertical spacing is correct.
  14299. The characters are about 0.5 to 0.75 units tall.
  14300.  
  14301. The horizontal spacing is handled by POV-Ray internally including any kerning
  14302. information stored in the font. The required vector OFFSET_VECTOR defines any
  14303. extra translation between each character. Normally you should specify a zero
  14304. for this value. Specifing 0.1*x would put additional 0.1 units of space
  14305. between each character.
  14306.  
  14307. Only printable characters are allowed in text objects. Characters such as
  14308. return, line feed, tabs, backspace etc. are not supported.
  14309.  
  14310. 7.5.2.13         Torus
  14311.  
  14312. A torus is a 4th order quartic polynomial shape that looks like a donut or
  14313. inner tube. Because this shape is so useful and quartics are difficult to
  14314. define, POV-Ray lets you take a short-cut and define a torus by:
  14315.  
  14316.   torus {
  14317.     MAJOR, MINOR
  14318.     [ sturm ]
  14319.   }
  14320.  
  14321.  
  14322. where MAJOR is a float value giving the major radius and MINOR is a float
  14323. specifying the minor radius. The major radius extends from the center of the
  14324. hole to the mid-line of the rim while the minor radius is the radius of the
  14325. cross-section of the rim. The torus is centered at the origin and lies in the
  14326. x-z-plane with the y-axis sticking through the hole.
  14327.  
  14328. |---------------------------------------------------------------|
  14329. |                                                               |
  14330. |    ----------- - - - - - - - ----------              +Y       |
  14331. |   /                        /                        |       |
  14332. |  /                        /                         |       |
  14333. | |              |          |       |<-B-->|       -X---|---+X  |
  14334. |              /                        /             |       |
  14335. |   __________/_ _ _ _ _ _ _ __________/              |       |
  14336. |                     |<-----A----->|                  -Y       |
  14337. |                                                               |
  14338. |  A = Major Radius                                             |
  14339. |  B = Minor Radius                                             |
  14340. |                                                               |
  14341. |---------------------------------------------------------------|
  14342. Major and minor radius of a torus.
  14343.  
  14344. The torus is internally bounded by two cylinders and two rings forming a
  14345. thick cylinder. With this bounding cylinder the performance of the torus
  14346. intersection test is vastly increased. The test for a valid torus
  14347. intersection, i. e. solving a 4th order polynomial, is only performed if the
  14348. bounding cylinder is hit. Thus a lot of slow root solving calculations are
  14349. avoided.
  14350.  
  14351. Calculations for all higher order polynomials must be very accurate. If the
  14352. torus renders improperly you may add the keyword sturm after the MINOR value
  14353. to use POV-Ray's slower-yet-more-accurate Sturmian root solver.
  14354.  
  14355. 7.5.3            Finite Patch Primitives
  14356.  
  14357. There are six totally thin, finite objects which have no well-defined inside.
  14358. They are bicubic patch, disc, smooth triangle, triangle, polygon and mesh.
  14359. They may be combined in CSG union but cannot be use in other types of CSG (or
  14360. inside a clipped_by statement). Because these types are finite POV-Ray can
  14361. use automatic bounding on them to speed up rendering time. As with all shapes
  14362. they can be translated, rotated and scaled.
  14363.  
  14364. 7.5.3.1          Bicubic Patch
  14365.  
  14366. A bicubic patch is a 3D curved surface created from a mesh of triangles.
  14367. POV-Ray supports a type of bicubic patch called a Bezier patch. A bicubic
  14368. patch is defined as follows:
  14369.  
  14370.   bicubic_patch {
  14371.     type PATCH_TYPE
  14372.     flatness FLATNESS_VALUE
  14373.     u_steps NUM_U_STEPS
  14374.     v_steps NUM_V_STEPS
  14375.     <CP1>,  <CP2>,   <CP3>,   <CP4>,
  14376.     <CP5>,  <CP6>,   <CP7>,   <CP8>,
  14377.     <CP9>,  <CP10>,  <CP11>,  <CP12>,
  14378.     <CP13>, <CP14>,  <CP15>,  <CP16>
  14379.   }
  14380.  
  14381.  
  14382. The keyword type is followed by a float PATCH_TYPE which currently must be
  14383. either 0 or 1. For type 0 only the control points are retained within
  14384. POV-Ray. This means that a minimal amount of memory is needed but POV-Ray
  14385. will need to perform many extra calculations when trying to render the patch.
  14386. Type 1 preprocesses the patch into many subpatches. This results in a
  14387. significant speedup in rendering at the cost of memory.
  14388.  
  14389. The four parameters type, flatness, u_steps and v_steps may appear in any
  14390. order. They are followed by 16 vectors that define the x, y, z coordinates of
  14391. the 16 control points which define the patch. The patch touches the four
  14392. corner points <CP1>, <CP4>, < CP13> and <CP16> while the other 12 points pull
  14393. and stretch the patch into shape. The Bezier surface is enclosed by the
  14394. convex hull formed by the 16 control points, this is known as the convex hull
  14395. property.
  14396.  
  14397. The keywords u_steps and v_steps are each followed by float values which tell
  14398. how many rows and columns of triangles are the minimum to use to create the
  14399. surface. The maximum number of individual pieces of the patch that are tested
  14400. by POV-Ray can be calculated from the following:
  14401.  
  14402.   sub-pieces = 2^u_steps * 2^v_steps
  14403.  
  14404.  
  14405. This means that you really should keep u_steps and v_steps under 4. Most
  14406. patches look just fine with u_steps  3 and v_steps 3, which translates to 64
  14407. subpatches (128 smooth triangles).
  14408.  
  14409. As POV-Ray processes the Bezier patch it makes a test of the current piece of
  14410. the patch to see if it is flat enough to just pretend it is a rectangle. The
  14411. statement that controls this test is flatness. Typical flatness values range
  14412. from 0 to 1 (the lower the slower).
  14413.  
  14414. If the value for flatness is 0 POV-Ray will always subdivide the patch to the
  14415. extend specified by u_steps and v_steps. If flatness is greater than 0 then
  14416. every time the patch is split, POV-Ray will check to see if there is any need
  14417. to split further.
  14418.  
  14419. There are both advantages and disadvantages to using a non-zero flatness. The
  14420. advantages include:
  14421.  
  14422.   - If the patch isn't very curved, then this will be detected and POV-Ray
  14423.   - If the patch is only highly curved in a couple of places, POV-Ray will
  14424.     keep subdividing there and concentrate it's efforts on the hard part.
  14425.  
  14426.  
  14427. The biggest disadvantage is that if POV-Ray stops subdividing at a particular
  14428. level on one part of the patch and at a different level on an adjacent part
  14429. of the patch there is the potential for cracking. This is typically visible
  14430. as spots within the patch where you can see through. How bad this appears
  14431. depends very highly on the angle at which you are viewing the patch.
  14432.  
  14433. Like triangles, the bicubic patch is not meant to be generated by hand. These
  14434. shapes should be created by a special utility. You may be able to acquire
  14435. utilities to generate these shapes from the same source from which you
  14436. obtained POV-Ray.
  14437.  
  14438.   bicubic_patch {
  14439.     type 1
  14440.     flatness 0.01
  14441.     u_steps 4
  14442.     v_steps 4
  14443.     <0, 0, 2>, <1, 0, 0>, <2, 0, 0>, <3, 0,-2>,
  14444.     <0, 1  0>, <1, 1, 0>, <2, 1, 0>, <3, 1, 0>,
  14445.     <0, 2, 0>, <1, 2, 0>, <2, 2, 0>, <3, 2, 0>,
  14446.     <0, 3, 2>, <1, 3, 0>, <2, 3, 0>, <3, 3, -2>
  14447.   }
  14448.  
  14449.  
  14450. The triangles in a POV-Ray bicubic_patch are automatically smoothed using
  14451. normal interpolation but it is up to the user (or the user's utility program)
  14452. to create control points which smoothly stitch together groups of patches.
  14453.  
  14454. 7.5.3.2          Disc
  14455.  
  14456. One other flat, finite object available with POV-Ray is the disc. The disc is
  14457. infinitely thin, it has no thickness. If you want a disc with true thickness
  14458. you should use a very short cylinder. A disc shape may be defined by:
  14459.  
  14460.   disc {
  14461.     <CENTER>, <NORMAL>, RADIUS [, HOLE_RADIUS ]
  14462.   }
  14463.  
  14464.  
  14465. The vector <CENTER> defines the x, y, z coordinates of the center of the
  14466. disc. The < NORMAL> vector describes its orientation by describing its
  14467. surface normal vector. This is followed by a float specifying the RADIUS.
  14468. This may be optionally followed by another float specifying the radius of a
  14469. hole to be cut from the center of the disc.
  14470.  
  14471. 7.5.3.3          Mesh
  14472.  
  14473. The mesh object can be used to efficiently store large numbers of triangles.
  14474. Its syntax is:
  14475.  
  14476.   mesh {
  14477.     triangle {
  14478.       <CORNER1>, <CORNER2>, <CORNER3>
  14479.       [ texture { STRING } ]
  14480.     }
  14481.     smooth_triangle {
  14482.       <CORNER1>, <NORMAL1>,
  14483.       <CORNER2>, <NORMAL2>,
  14484.       <CORNER3>, <NORMAL3>
  14485.       [ texture { STRING } ]
  14486.     }
  14487.     [ hierarchy FLAG ]
  14488.   }
  14489.  
  14490.  
  14491. Any number of triangles and/or smooth triangles can be used and each of those
  14492. triangles can be individually textured by assigning a texture name to it. The
  14493. texture has to be declared before the mesh is parsed. It is not possible to
  14494. use texture definitions inside the triangle or smooth triangle statements.
  14495. This is a restriction that is necessary for an efficient storage of the
  14496. assigned textures.
  14497.  
  14498. The mesh's components are internally bounded by a bounding box hierarchy to
  14499. speed up intersection testing. The bounding hierarchy can be turned off with
  14500. the hierarchy keyword. This should only be done if memory is short or the
  14501. mesh consists of only a few triangles.
  14502.  
  14503. Copies of a mesh object refer to the same triangle data and thus consume very
  14504. little memory. You can easily trace hundred copies of an 10000 triangle mesh
  14505. without running out of memory (assuming the first mesh fits into memory).
  14506.  
  14507. The mesh object has two advantages over a union of triangles: it needs less
  14508. memory and it is transformed faster. The memory requirements are reduced by
  14509. efficiently storing the triangles vertices and normals. The parsing time for
  14510. transformed meshes is reduced because only the mesh object has to be
  14511. transformed and not every single triangle as it is necessary for unions.
  14512.  
  14513. The mesh object can currently only include triangle and smooth triangle
  14514. components. That restriction is liable to change, allowing polygonal
  14515. components, at some point in the future.
  14516.  
  14517. 7.5.3.4          Polygon
  14518.  
  14519. Polygons are useful for creating rectangles, squares and other planar shapes
  14520. with more than three edges. Their syntax is:
  14521.  
  14522.   polygon {
  14523.     TOTAL_NUMBER_OF_POINTS,
  14524.     <A_1>, <A_2>, ..., <A_na>, <A_1>,
  14525.     <B_1>, <B_2>, ..., <B_nb>, <B_1>,
  14526.     <C_1>, <C_2>, ..., <C_nc>, <C_1>,
  14527.     ...
  14528.   }
  14529.  
  14530.  
  14531. The points <A_1> through <A_na> describe the first sub-polygon, the points
  14532. <B_1> through <B_nb> describe the second sub-polygon, and so on. A polygon
  14533. can contain any number of sub-polygons, either overlapping or not. In places
  14534. where an even number of polygons overlaps a hole appears. You only have to be
  14535. sure that each of these polygons is closed. This is insured by repeating the
  14536. first point of a sub-polygon at the end of the sub-polygon's point sequence.
  14537. This implies that all points of a sub-polygon are different.
  14538.  
  14539. If the (last) sub-polygon is not closed a warning is issued and the program
  14540. automatically closes the polygon. This is useful because polygons imported
  14541. from other programs may not be closed, i. e. their first and last point are
  14542. not the same.
  14543.  
  14544. All points of a polygon are three-dimensional vectors that have to lay on one
  14545. plane. If this is not the case an error occurs. You can also use
  14546. two-dimensional vectors to describe the polygon. POV-Ray assumes that the z
  14547. value is zero in this case.
  14548.  
  14549. A square polygon that matches the default planar imagemap is simply:
  14550.  
  14551.   polygon {
  14552.     4,
  14553.     <0, 0>, <0, 1>, <1, 1>, <1, 0>
  14554.     texture {
  14555.       finish { ambient 1 diffuse 0 }
  14556.       pigment { image_map { gif "test.gif"  } }
  14557.     }
  14558.     //scale and rotate as needed here
  14559.   }
  14560.  
  14561.  
  14562. The sub-polygon feature can be used to generate complex shapes like the
  14563. letter "P", where a hole is cut into another polygon:
  14564.  
  14565.   #declare P = polygon {
  14566.     12,
  14567.     <0, 0>, <0, 6>, <4, 6>, <4, 3>, <1, 3>, <1, 0>, <0, 0>,
  14568.     <1, 4>, <1, 5>, <3, 5>, <3, 4>, <1, 4>
  14569.   }
  14570.  
  14571.  
  14572. The first sub-polygon (on the first line) describes the outer shape of the
  14573. letter "P". The second sub-polygon (on the second line) describes the
  14574. rectangular hole that is cut in the top of the letter "P". Both rectangles
  14575. are closed, i. e. their first and last points are the same.
  14576.  
  14577. The feature of cutting holes into a polygon is based on the polygon
  14578. inside/outside test used. A point is considered to be inside a polygon if a
  14579. straight line drawn from this point in an arbitrary direction crosses an odd
  14580. number of edges (this is known as Jordan's curve  theorem).
  14581.  
  14582. Another very complex example showing one large triangle with three small
  14583. holes and three separate, small triangles is given below:
  14584.  
  14585.   polygon {
  14586.     28,
  14587.     <0, 0> <1, 0> <0, 1> <0, 0>          // large outer triangle
  14588.     <.3, .7> <.4, .7> <.3, .8> <.3, .7>  // small outer triangle #1
  14589.     <.5, .5> <.6, .5> <.5, .6> <.5, .5>  // small outer triangle #2
  14590.     <.7, .3> <.8, .3> <.7, .4> <.7, .3>  // small outer triangle #3
  14591.     <.5, .2> <.6, .2> <.5, .3> <.5, .2>  // inner triangle #1
  14592.     <.2, .5> <.3, .5> <.2, .6> <.2, .5>  // inner triangle #2
  14593.     <.1, .1> <.2, .1> <.1, .2> <.1, .1>  // inner triangle #3
  14594.   }
  14595.  
  14596.  
  14597. 7.5.3.5          Triangle and Smooth Triangle
  14598.  
  14599. The triangle primitive is available in order to make more complex objects
  14600. than the built-in shapes will permit. Triangles are usually not created by
  14601. hand but are converted from other files or generated by utilities. A triangle
  14602. is defined by
  14603.  
  14604.   triangle {
  14605.     <CORNER1>, <CORNER2>, <CORNER3>
  14606.   }
  14607.  
  14608.  
  14609. where <CORNERn> is a vector defining the x, y, z coordinates of each corner
  14610. of the triangle.
  14611.  
  14612. Because triangles are perfectly flat surfaces it would require extremely
  14613. large numbers of very small triangles to approximate a smooth, curved
  14614. surface. However much of our perception of smooth surfaces is dependent upon
  14615. the way light and shading is done. By artificially modifying the surface
  14616. normals we can simulate as smooth surface and hide the sharp-edged seams
  14617. between individual triangles.
  14618.  
  14619. The smooth triangle primitive is used for just such purposes. The smooth
  14620. triangles use a formula called Phong normal interpolation to calculate the
  14621. surface normal for any point on the triangle based on normal vectors which
  14622. you define for the three corners. This makes the triangle appear to be a
  14623. smooth curved surface. A smooth triangle is defined by
  14624.  
  14625.   smooth_triangle {
  14626.     <CORNER1>, <NORMAL1>,
  14627.     <CORNER2>, <NORMAL2>,
  14628.     <CORNER3>, <NORMAL3>
  14629.   }
  14630.  
  14631.  
  14632. where the corners are defined as in regular triangles and < NORMALn> is a
  14633. vector describing the direction of the surface normal at each corner.
  14634.  
  14635. These normal vectors are prohibitively difficult to compute by hand.
  14636. Therefore smooth triangles are almost always generated by utility programs.
  14637. To achieve smooth results, any triangles which share a common vertex should
  14638. have the same normal vector at that vertex. Generally the smoothed normal
  14639. should be the average of all the actual normals of the triangles which share
  14640. that point.
  14641.  
  14642. 7.5.4            Infinite Solid Primitives
  14643.  
  14644. There are five polynomial primitive shapes that are possibly infinite and do
  14645. not respond to automatic bounding. They are plane, cubic, poly, quadric and
  14646. quartic. They do have a well defined inside and may be used in CSG and inside
  14647. a clipped_by statement. As with all shapes they can be translated, rotated
  14648. and scaled..
  14649.  
  14650. 7.5.4.1          Plane
  14651.  
  14652. The plane primitive is a simple way to define an infinite flat surface. The
  14653. plane is specified as follows:
  14654.  
  14655.   plane { <NORMAL>, DISTANCE }
  14656.  
  14657.  
  14658. The <NORMAL> vector defines the surface normal of the plane. A surface normal
  14659. is a vector which points up from the surface at a 90 degree angle. This is
  14660. followed by a float value that gives the distance along the normal that the
  14661. plane is from the origin (that is only true if the normal vector has unit
  14662. length; see below). For example:
  14663.  
  14664.   plane { <0, 1, 0>, 4 }
  14665.  
  14666.  
  14667. This is a plane where straight up is defined in the positive y-direction. The
  14668. plane is 4 units in that direction away from the origin. Because most planes
  14669. are defined with surface normals in the direction of an axis you will often
  14670. see planes defined using the x, y or z built-in vector identifiers. The
  14671. example above could be specified as:
  14672.  
  14673.   plane { y, 4 }
  14674.  
  14675.  
  14676. The plane extends infinitely in the x- and z-directions. It effectively
  14677. divides the world into two pieces. By definition the normal vector points to
  14678. the outside of the plane while any points away from the vector are defined as
  14679. inside. This inside/outside distinction is only important when using planes
  14680. in CSG and clipped_by.
  14681.  
  14682. A plane is called a polynomial shape because it is defined by a first order
  14683. polynomial equation. Given a plane:
  14684.  
  14685.   plane { <A, B, C>, D }
  14686.  
  14687.  
  14688. it can be represented by the equation
  14689.  
  14690.   A*x + B*y + C*z - D*sqrt(A^2 + B^2 + C^2) = 0.
  14691.  
  14692.  
  14693. Therefore our example plane { y,4 } is actually the polynomial equation y=4.
  14694. You can think of this as a set of all x, y, z points where all have y values
  14695. equal to 4, regardless of the x or z values.
  14696.  
  14697. This equation is a first order polynomial because each term contains only
  14698. single powers of x, y or z. A second order equation has terms like x^2, y^2,
  14699. z^2, xy, xz and yz. Another name for a 2nd order equation is a quadric
  14700. equation. Third order polys are called cubics. A 4th order equation is a
  14701. quartic. Such shapes are described in the sections below.
  14702.  
  14703. 7.5.4.2          Poly, Cubic and Quartic
  14704.  
  14705. Higher order polynomial surfaces may be defined by the use of a poly shape.
  14706. The syntax is
  14707.  
  14708.   poly { ORDER, <T1, T2, T3, .... Tm> }
  14709.  
  14710.  
  14711. where ORDER is an integer number from 2 to 7 inclusively that specifies the
  14712. order of the equation. T1, T2, ... Tm are float values for the coefficients
  14713. of the equation. There are m such terms where
  14714.  
  14715.   m = ((ORDER+1)*(ORDER+2)*(ORDER+3))/6.
  14716.  
  14717.  
  14718. An alternate way to specify 3rd order polys is:
  14719.  
  14720.   cubic { <T1, T2,... T20> }
  14721.  
  14722.  
  14723. Also 4th order equations may be specified with:
  14724.  
  14725.   quartic { <T1, T2,... T35> }
  14726.  
  14727.  
  14728. Here's a more mathematical description of quartics for those who are
  14729. interested. Quartic surfaces are 4th order surfaces and can be used to
  14730. describe a large class of shapes including the torus, the lemniscate, etc.
  14731. The general equation for a quartic equation in three variables is (hold onto
  14732. your hat):
  14733.  
  14734.   a00 x^4 + a01 x^3 y + a02 x^3 z+ a03 x^3 + a04 x^2 y^2+
  14735.   a05 x^2 y z+ a06 x^2 y + a07 x^2 z^2+a08 x^2 z+a09 x^2+
  14736.   a10 x y^3+a11 x y^2 z+ a12 x y^2+a13 x y z^2+a14 x y z+
  14737.   a15 x y + a16 x z^3 + a17 x z^2 + a18 x z + a19 x+
  14738.   a20 y^4 + a21 y^3 z + a22 y^3+ a23 y^2 z^2 +a24 y^2 z+
  14739.   a25 y^2 + a26 y z^3 + a27 y z^2 + a28 y z + a29 y+
  14740.   a30 z^4 + a31 z^3 + a32 z^2 + a33 z + a34 = 0
  14741.  
  14742.  
  14743. To declare a quartic surface requires that each of the coefficients (a0 ...
  14744. a34) be placed in order into a single long vector of 35 terms.
  14745.  
  14746. As an example let's define a torus the hard way. A Torus can be represented
  14747. by the equation:
  14748.  
  14749.  x^4 + y^4 + z^4 + 2 x^2 y^2 + 2 x^2 z^2 + 2 y^2 z^2 -
  14750.  2 (r_0^2 + r_1^2) x^2 + 2 (r_0^2 - r_1^2) y^2 -
  14751.  2 (r_0^2 + r_1^2) z^2 + (r_0^2 - r_1^2)^2 = 0
  14752.  
  14753.  
  14754. Where r_0 is the major radius of the torus, the distance from the hole of the
  14755. donut to the middle of the ring of the donut, and r_1 is the minor radius of
  14756. the torus, the distance from the middle of the ring of the donut to the outer
  14757. surface. The following object declaration is for a torus having major radius
  14758. 6.3 minor radius 3.5 (Making the maximum width just under 20).
  14759.  
  14760.   // Torus having major radius sqrt(40), minor radius sqrt(12)
  14761.  
  14762.   quartic {
  14763.     < 1,   0,   0,   0,   2,   0,   0,   2,   0,
  14764.    -104,   0,   0,   0,   0,   0,   0,   0,   0,
  14765.       0,   0,   1,   0,   0,   2,   0,  56,   0,
  14766.       0,   0,   0,   1,   0, -104,  0, 784 >
  14767.     sturm
  14768.     bounded_by { // bounded_by speeds up the render,
  14769.                  // see bounded_by
  14770.                  // explanation later
  14771.                  // in docs for more info.
  14772.      sphere { <0, 0, 0>, 10 }
  14773.     }
  14774.   }
  14775.  
  14776.  
  14777. Poly, cubic and quartics are just like quadrics in that you don't have to
  14778. understand what one is to use one. The file shapesq.inc has plenty of
  14779. pre-defined quartics for you to play with. The syntax for using a pre-defined
  14780. quartic is:
  14781.  
  14782.   object { Quartic_Name }
  14783.  
  14784.  
  14785. Polys use highly complex computations and will not always render perfectly.
  14786. If the surface is not smooth, has dropouts, or extra random pixels, try using
  14787. the optional keyword sturm in the definition. This will cause a slower but
  14788. more accurate calculation method to be used. Usually, but not always, this
  14789. will solve the problem. If sturm doesn't work, try rotating or translating
  14790. the shape by some small amount. See the sub-directory math in the scene files
  14791. directory for examples of polys in scenes.
  14792.  
  14793. There are really so many different quartic shapes, we can't even begin to
  14794. list or describe them all. If you are interested and mathematically inclined,
  14795. an excellent reference book for curves and surfaces where you'll find more
  14796. quartic shape formulas is:
  14797.  
  14798.   "The CRC Handbook of Mathematical Curves and Surfaces"
  14799.   David von Seggern
  14800.   CRC Press, 1990
  14801.  
  14802.  
  14803. 7.5.4.3          Quadric
  14804.  
  14805. Quadric surfaces can produce shapes like ellipsoids, spheres, cones,
  14806. cylinders, paraboloids (dish shapes) and hyperboloids (saddle or hourglass
  14807. shapes). Note that you do not confuse quaDRic with quaRTic. A quadric is a
  14808. 2nd order polynomial while a quartic is 4th order. Quadrics render much
  14809. faster and are less error-prone.
  14810.  
  14811. A quadric is defined in POV-Ray by
  14812.  
  14813.   quadric { <A,B,C>, <D,E,F>, <G,H,I>, J }
  14814.  
  14815.  
  14816. where A through J are float expressions that define a surface of x, y, z
  14817. points which satisfy the equation
  14818.  
  14819.   A x^2   + B y^2   + C z^2 +
  14820.   D xy    + E xz    + F yz +
  14821.   G x     + H y     + I z    + J = 0
  14822.  
  14823.  
  14824. Different values of A, B, C, ... J will give different shapes. If you take
  14825. any three dimensional point and use its x, y and z coordinates in the above
  14826. equation the answer will be 0 if the point is on the surface of the object.
  14827. The answer will be negative if the point is inside the object and positive if
  14828. the point is outside the object. Here are some examples:
  14829.  
  14830.   X^2 + Y^2 + Z^2 - 1 = 0  Sphere
  14831.   X^2 + Y^2 - 1 = 0        Infinite cylinder along the Z axis
  14832.   X^2 + Y^2 - Z^2 = 0      Infinite cone along the Z axis
  14833.  
  14834.  
  14835. The easiest way to use these shapes is to include the standard file
  14836. shapes.inc into your program. It contains several pre-defined quadrics and
  14837. you can transform these pre-defined shapes (using translate, rotate and
  14838. scale) into the ones you want. You can invoke them by using the syntax:
  14839.  
  14840.   object { Quadric_Name }
  14841.  
  14842.  
  14843. The pre-defined quadrics are centered about the origin < 0,0,0> and have a
  14844. radius of 1. Don't confuse radius with width. The radius is half the diameter
  14845. or width making the standard quadrics 2 units wide.
  14846.  
  14847. Some of the pre-defined quadrics are,
  14848.  
  14849.   Ellipsoid
  14850.   Cylinder_X, Cylinder_Y, Cylinder_Z
  14851.   QCone_X, QCone_Y, QCone_Z
  14852.   Paraboloid_X, Paraboloid_Y, Paraboloid_Z
  14853.  
  14854.  
  14855. 7.5.5            Constructive Solid Geometry
  14856.  
  14857. POV-Ray supports Constructive Solid Geometry (CSG) with five different
  14858. operations: difference, intersection, merge, union and negation (inversion).
  14859. While the first four operations represent binary operators, i. e. they need
  14860. two arguments, the negation is a unary operator, it takes only one argument.
  14861.  
  14862. 7.5.5.1          About CSG
  14863.  
  14864. Constructive Solid Geometry is a technique for combining two or more objects
  14865. to create a new object using the three boolean set operators union,
  14866. intersection, and negation. It only works with solid objects, i. e. objects
  14867. that have a well-defined interior. This is the case for all objects described
  14868. in the sections "Finite Solid Primitives" and "Infinite Solid Primitives".
  14869.  
  14870. CSG shapes may be used anywhere a standard shape can be used, even inside
  14871. other CSG shapes. They can be translated, rotated or scaled in the same way
  14872. as any other shape. The shapes making up the CSG shape may be individually
  14873. translated, rotated and scaled as well.
  14874.  
  14875. 7.5.5.2          Inside and Outside
  14876.  
  14877. Most shape primitives, like spheres, boxes and blobs divide the world into
  14878. two regions. One region is inside the object and one is outside.
  14879.  
  14880. Given any point in space you can say it's either inside or outside any
  14881. particular primitive object. Well, it could be exactly on the surface but
  14882. this case is rather hard to determine due to numerical problems.
  14883.  
  14884. Even planes have an inside and an outside. By definition, the surface normal
  14885. of the plane points towards the outside of the plane. You should note that
  14886. triangles and triangle-based shapes cannot be used as solid objects in CSG
  14887. since they have no well defined inside and outside.
  14888.  
  14889. CSG uses the concepts of inside and outside to combine shapes together as
  14890. explained in the following sections.
  14891.  
  14892. Imagine you have to objects that partially overlap like shown in the figure
  14893. below. Four different areas of points can be distinguished: points that are
  14894. neither in object A nor in object B, points that are in object A but not in
  14895. object B, points that are not in object A but in object B and last not least
  14896. points that are in object A and object B.
  14897.  
  14898. * = Object A
  14899. % = Object B
  14900.  
  14901.          *
  14902.         * *    %
  14903.        *   *  % %
  14904.       *     *%   %
  14905.      *      %*    %
  14906.     *      %  *    %
  14907.    *      %    *    %
  14908.   *******%*******    %
  14909.         %             %
  14910.        %%%%%%%%%%%%%%%%%
  14911. Two overlapping objects.
  14912.  
  14913. Keeping this in mind it will be quite easy to understand how the CSG
  14914. operations work.
  14915.  
  14916. 7.5.5.3          Inverse
  14917.  
  14918. When using CSG it is often useful to invert an object so that it'll be
  14919. inside-out. The appearance of the object is not changed, just the way that
  14920. POV-Ray perceives it. When the inverse keyword is used the inside of the
  14921. shape is flipped to become the outside and vice versa.
  14922.  
  14923. Note that the difference operation is performed by intersecting the first
  14924. object with the negation of the second object.
  14925.  
  14926. 7.5.5.4          Union
  14927.  
  14928.          *
  14929.         * *    %
  14930.        *   *  % %
  14931.       *     *%   %
  14932.      *      %*    %
  14933.     *      %  *    %
  14934.    *      %    *    %
  14935.   *******%*******    %
  14936.         %             %
  14937.        %%%%%%%%%%%%%%%%%
  14938. The union of two objects.
  14939.  
  14940. Unions are simply glue used to bind two or more shapes into a single entity
  14941. that can be manipulated as a single object. The image above shows the union
  14942. of A and B. The new object created by the union operation can be scaled,
  14943. translated and rotated as a single shape. The entire union can share a single
  14944. texture but each object contained in the union may also have its own texture,
  14945. which will override any matching texture statements in the parent object.
  14946.  
  14947. You should be aware that the surfaces inside the union will not be removed.
  14948. As you can see from the figure this may be a problem for transparent unions.
  14949. If you want those surfaces to be removed you'll have to use the merge
  14950. operations explained in a later section.
  14951.  
  14952. The following union will contain a box and a sphere.
  14953.  
  14954.   union {
  14955.     box { <-1.5, -1, -1>, <0.5, 1, 1> }
  14956.     cylinder { <0.5, 0, -1>, <0.5, 0, 1>, 1 }
  14957.   }
  14958.  
  14959.  
  14960. Earlier versions of POV-Ray placed restrictions on unions so you often had to
  14961. combine objects with composite statements. Those earlier restrictions have
  14962. been lifted so composite is no longer needed. Composite is still supported
  14963. for backwards compatibility but it is recommended that union is now used in
  14964. it's place since future support for the composite keyword is not guaranteed.
  14965.  
  14966. 7.5.5.5          Intersection
  14967.  
  14968. A point is inside an intersection if it is inside both objects, A and B, as
  14969. show in the figure below.
  14970.  
  14971.           %*
  14972.          %  *
  14973.         %    *
  14974.        %*******
  14975. The intersection of two objects.
  14976.  
  14977. For example:
  14978.  
  14979.   intersection {
  14980.     box { <-1.5, -1, -1>, <0.5, 1, 1> }
  14981.     cylinder { <0.5, 0, -1>, <0.5, 0, 1>, 1 }
  14982.   }
  14983.  
  14984.  
  14985. 7.5.5.6          Difference
  14986.  
  14987. The CSG difference operation takes the intersection between the first object
  14988. and the negation of the second object. Thus only points inside object A and
  14989. outside object B belong to the difference of both objects.
  14990.  
  14991. The results is a subtraction of the 2nd shape from the first shape as shown
  14992. in the figure below.
  14993.  
  14994.        *
  14995.       * *
  14996.      *   *
  14997.     *     *
  14998.    *  1   %
  14999.   *      %
  15000.  *      %
  15001. *******%
  15002. The difference between two objects.
  15003.  
  15004. For example:
  15005.  
  15006.   difference {
  15007.     box { <-1.5, -1, -1>, <0.5, 1, 1> }
  15008.     cylinder { <0.5, 0, -1>, <0.5, 0, 1>, 1 }
  15009.   }
  15010.  
  15011.  
  15012. 7.5.5.7          Merge
  15013.  
  15014. The union operation just glues objects together, it does not remove the
  15015. objects' surfaces inside the union. If a transparent union is used those
  15016. surface will get visible.
  15017.  
  15018. The merge operations can be used to avoid this problem. It works just like
  15019. union but it eliminates the inner surfaces like shown in the figure below.
  15020.  
  15021.          *
  15022.         * *    %
  15023.        *   *  % %
  15024.       *     *%   %
  15025.      *            %
  15026.     *              %
  15027.    *                %
  15028.   *******%           %
  15029.         %             %
  15030.        %%%%%%%%%%%%%%%%%
  15031. Merge removes inner surfaces.
  15032.  
  15033. 7.5.6            Light Sources
  15034.  
  15035. The last object covered is the light source. Light sources have no visible
  15036. shape of their own. They are just points or areas which emit light. Their
  15037. full syntax is:
  15038.  
  15039.   light_source {
  15040.     <LOCATION>
  15041.     color <COLOUR>
  15042.     [ spotlight ]
  15043.     [ point_at <POINT_AT> ]
  15044.     [ radius RADIUS ]
  15045.     [ falloff FALLOFF ]
  15046.     [ tightness TIGHTNESS ]
  15047.     [ area_light <AXIS1>, <AXIS2>, SIZE1, SIZE2 ]
  15048.     [ adaptive ADAPTIVE ]
  15049.     [ jitter JITTER ]
  15050.     [ looks_like { OBJECT } ]
  15051.     [ fade_distance FADE_DISTANCE ]
  15052.     [ fade_power FADE_POWER ]
  15053.     [ atmospheric_attenuation BOOL ]
  15054.   }
  15055.  
  15056.  
  15057. The different types of light sources and the optional modifiers are described
  15058. in the following sections.
  15059.  
  15060. 7.5.6.1          Point Lights
  15061.  
  15062. A point light source sends light of the specified color uniformly in all
  15063. directions. Its location is described by the location keyword and its color
  15064. is given by the color keyword. The complete syntax is:
  15065.  
  15066.   light_source {
  15067.     <LOCATION>
  15068.     color <COLOUR>
  15069.     [ looks_like { OBJECT } ]
  15070.     [ fade_distance FADE_DISTANCE ]
  15071.     [ fade_power FADE_POWER ]
  15072.     [ atmospheric_attenuation BOOL ]
  15073.   }
  15074.  
  15075.  
  15076. 7.5.6.2          Spotlights
  15077.  
  15078. A spotlight is a point light source where the rays of light are constrained
  15079. by a cone. The light is bright in the center of this cone and falls off or
  15080. darkens at the edges of the cone. The syntax is:
  15081.  
  15082.   light_source {
  15083.     <LOCATION>
  15084.     color <COLOUR>
  15085.     spotlight
  15086.     point_at <POINT_AT>
  15087.     radius RADIUS
  15088.     falloff FALLOFF
  15089.     tightness TIGHTNESS
  15090.     [ looks_like { OBJECT } ]
  15091.     [ fade_distance FADE_DISTANCE ]
  15092.     [ fade_power FADE_POWER ]
  15093.     [ atmospheric_attenuation BOOL ]
  15094.   }
  15095.  
  15096.  
  15097. The spotlight is identified by the spotlight keyword. It is located at
  15098. LOCATION and points at POINT_AT. The following illustration will be helpful
  15099. in understanding how these values relate to each other.
  15100.  
  15101.      (+) location
  15102.      / \
  15103.     /   \
  15104.    /     \
  15105.   /       \
  15106.  /         \
  15107. /           \
  15108. +-----*-----+
  15109.       ^ point_at
  15110. The geometry of a spotlight.
  15111.  
  15112. The spotlight's other parameters are radius, falloff and tightness.
  15113.  
  15114. Think of a spotlight as two nested cones as shown in the figure. The inner
  15115. cone is specified by the radius parameter and is fully lit. The outer cone is
  15116. the falloff cone beyond which there is no light. The values for these two
  15117. parameters are half the opening angles of the corresponding cones, both
  15118. angles have to be smaller than 90 degrees. The light smoothly falls off
  15119. between the radius and the falloff angle like shown in the figures below (as
  15120. long as the radius angle is not negative).
  15121.  
  15122. Intensity multiplier curve with a fixed falloff angle of 45 degrees.
  15123.  
  15124. Intensity multiplier curve with a fixed radius angle of 45 degrees.
  15125.  
  15126. The tightness value specifies how quickly the light dims, or falls off, from
  15127. the spotlight's center line to the falloff cone (full darkness outside). The
  15128. default value for tightness is 10. Lower tightness values will make the
  15129. spotlight brighter, making the spot wider and the edges sharper. Higher
  15130. values will dim the spotlight, making the spot tighter and the edges softer.
  15131. Values from 1 to 100 are acceptable.
  15132.  
  15133. Intensity multiplier curve with fixed angle and falloff angles of 30 and 60
  15134. degrees respectively and different tightness values.
  15135.  
  15136. You should note from the figures that the radius and falloff angles interact
  15137. with the tightness parameter. Only negative radius angles will give the
  15138. tightness value full control over the spotlight's appearance as you can see
  15139. from the figure below. In that case the falloff angle has no effect and the
  15140. lit area is only determined by the tightness parameter.
  15141.  
  15142. Intensity multiplier curve with a negative radius angle and different
  15143. tightness values.
  15144.  
  15145. Spotlights may be used anyplace that a normal light source is used. Like any
  15146. light sources, they are invisible. They are treated as shapes and may be
  15147. included in CSG shapes. They may also be used in conjunction with area
  15148. lights.
  15149.  
  15150. 7.5.6.3          Cylindrical Lights
  15151.  
  15152. Cylindrical light sources work pretty much like spotlights except that the
  15153. light rays are constraint by a cylinder and not a cone. The syntax is:
  15154.  
  15155.   light_source {
  15156.     <LOCATION>
  15157.     color <COLOUR>
  15158.     cylinder
  15159.     point_at <POINT_AT>
  15160.     radius RADIUS
  15161.     falloff FALLOFF
  15162.     tightness TIGHTNESS
  15163.     [ looks_like { OBJECT } ]
  15164.     [ fade_distance FADE_DISTANCE ]
  15165.     [ fade_power FADE_POWER ]
  15166.     [ atmospheric_attenuation BOOL ]
  15167.   }
  15168.  
  15169.  
  15170. The radius, falloff and tightness keywords control the same features as with
  15171. the spotlight.
  15172.  
  15173. You should keep in mind that the cylindrical light source is still a point
  15174. light source. The rays are emitted from one point and are only constraint by
  15175. a cylinder. The light rays are not parallel.
  15176.  
  15177. 7.5.6.4          Area Lights
  15178.  
  15179. Area light sources occupy a finite, one- or two-dimensional area of space.
  15180. They can cast soft shadows because they can partially block light.
  15181.  
  15182. The area lights used in POV-Ray are rectangular in shape, sort of like a flat
  15183. panel light. Rather than performing the complex calculations that would be
  15184. required to model a true area light, it is approximated as an array of point
  15185. light sources spread out over the area occupied by the light. The intensity
  15186. of each individual point light in the array is dimmed so that the total
  15187. amount of light emitted by the light is equal to the light color specified in
  15188. the declaration. The syntax is:
  15189.  
  15190.   light_source {
  15191.     <LOCATION>
  15192.     color <COLOUR>
  15193.     area_light <AXIS1>, <AXIS2>, SIZE1, SIZE2
  15194.     adaptive ADAPTIVE
  15195.     jitter JITTER
  15196.     [ spotlight ]
  15197.     [ point_at <POINT_AT> ]
  15198.     [ radius RADIUS ]
  15199.     [ falloff FALLOFF ]
  15200.     [ tightness TIGHTNESS ]
  15201.     [ looks_like { OBJECT } ]
  15202.     [ fade_distance FADE_DISTANCE ]
  15203.     [ fade_power FADE_POWER ]
  15204.     [ atmosphere BOOL ]
  15205.     [ atmospheric_attenuation BOOL ]
  15206.   }
  15207.  
  15208.  
  15209. The light's location and color are specified in the same way as a for a
  15210. regular light source.
  15211.  
  15212. The area_light command defines the size and orientation of the area light as
  15213. well as the number of lights in the light source array. The vectors AXIS1 and
  15214. AXIS2 specify the lengths and directions of the edges of the light. Since the
  15215. area lights are rectangular in shape these vectors should be perpendicular to
  15216. each other. The larger the size of the light the thicker the soft part of
  15217. shadows will be. The numbers SIZE1 and SIZE2 specify the dimensions of the
  15218. array of point lights. The more lights you use the smoother your shadows will
  15219. be but the longer they will take to render.
  15220.  
  15221. The jitter command is optional. When used it causes the positions of the
  15222. point lights in the array to be randomly jittered to eliminate any shadow
  15223. banding that may occur. The jittering is completely random from render to
  15224. render and should not be used when generating animations.
  15225.  
  15226. Note that it is possible to specify spotlight parameters along with the area
  15227. light parameters to create area spotlights. Using area spotlights is a good
  15228. way to speed up scenes that use area lights since you can confine the lengthy
  15229. soft shadow calculations to only the parts of your scene that need them.
  15230.  
  15231. An interesting effect can be created using a linear light source. Rather than
  15232. having a rectangular shape, a linear light stretches along a line sort of
  15233. like a thin fluorescent tube. To create a linear light just create an area
  15234. light with one of the array dimensions set to 1.
  15235.  
  15236. The adaptive command is used to enable adaptive sampling of the light source.
  15237. By default POV-Ray calculates the amount of light that reaches a surface from
  15238. an area light by shooting a test ray at every point light within the array.
  15239. As you can imagine this is very slow. Adaptive sampling on the other hand
  15240. attempts to approximate the same calculation by using a minimum number of
  15241. test rays. The number specified after the keyword controls how much adaptive
  15242. sampling is used. The higher the number the more accurate your shadows will
  15243. be but the longer they will take to render. If you're not sure what value to
  15244. use a good starting point is adaptive 1. The adaptive keyword only accepts
  15245. integer values and cannot be set lower than 0.
  15246.  
  15247. When performing adaptive sampling POV-Ray starts by shooting a test ray at
  15248. each of the four corners of the area light. If the amount of light received
  15249. from all four corners is approximately the same then the area light is
  15250. assumed to be either fully in view or fully blocked. The light intensity is
  15251. then calculated as the average intensity of the light received from the four
  15252. corners. However, if the light intensity from the four corners differs
  15253. significantly then the area light is partially blocked. The area light is
  15254. split into four quarters and each section is sampled as described above. This
  15255. allows POV-Ray to rapidly approximate how much of the area light is in view
  15256. without having to shoot a test ray at every light in the array. Visually the
  15257. sampling goes like shown below.
  15258.  
  15259.  level       0            1           2         3
  15260.  rays        4            9           25        81
  15261.          * . . . *    x . * . x   x * x * x
  15262.          . . . . .    . . . . .   * * * * *
  15263.          . . . . .    * . * . *   x * x * x    etc...
  15264.          . . . . .    . . . . .   * * * * *
  15265.          * . . . *    x . * . x   x * x * x
  15266.  
  15267.  * new samples
  15268.  x reused samples from previous level
  15269. Area light adaptive samples.
  15270.  
  15271. While the adaptive sampling method is fast (relatively speaking) it can
  15272. sometimes produces inaccurate shadows. The solution is to reduce the amount
  15273. of adaptive sampling without completely turning it off. The number after the
  15274. adaptive keyword adjusts the number of times that the area light will be
  15275. split before the adaptive phase begins. For example if you use adaptive 0 a
  15276. minimum of 4 rays will be shot at the light. If you use adaptive 1 a minimum
  15277. of 9 rays will be shot (adaptive 2 gives 25 rays, adaptive 3 gives 81 rays,
  15278. etc). Obviously the more shadow rays you shoot the slower the rendering will
  15279. be so you should use the lowest value that gives acceptable results.
  15280.  
  15281. The number of rays never exceeds the values you specify for rows and columns
  15282. of points. For example area_light x,y,4,4 specifies a 4 by 4 array of lights.
  15283. If you specify adaptive 3 it would mean that you should start with a 9 by 9
  15284. array. In this case no adaptive sampling is done. The 4 by 4 array is used.
  15285.  
  15286. 7.5.6.5          Shadowless Lights
  15287.  
  15288. Using the shadowless keyword you can stop a light source from casting
  15289. shadows.
  15290.  
  15291. 7.5.6.6          Looks_like
  15292.  
  15293. Normally the light source itself has no visible shape. The light simply
  15294. radiates from an invisible point or area. You may give a light source any
  15295. shape by adding a looks_like { OBJECT } statement.
  15296.  
  15297. There is an implied no_shadow attached to the looks_like object so that light
  15298. is not blocked by the object. Without the automatic no_shadow the light
  15299. inside the object would not escape. The object would, in effect, cast a
  15300. shadow over everything.
  15301.  
  15302. If you want the attached object to block light then you should attach it with
  15303. a union and not a looks_like as follows:
  15304.  
  15305.   union {
  15306.     light_source { <100, 200, -300> color White }
  15307.     object { My_Lamp_Shape }
  15308.   }
  15309.  
  15310.  
  15311. 7.5.6.7          Light Fading
  15312.  
  15313. By default POV-Ray does not diminish light from any light source as it
  15314. travels through space. In order to get a more realistic effect fade_distance
  15315. and fade_power can be used to model the distance based falloff in light
  15316. intensity.
  15317.  
  15318. The fade_distance keyword is used to specify the distance at which the full
  15319. light intensity arrives, i. e. the intensity which was given by the color
  15320. keyword. The actual attenuation is described by the fade_power keyword, which
  15321. determines the falloff rate. E. g. linear or quadratic falloff can be used by
  15322. setting FADE_POWER to 1 or 2 respectively. The complete formula to calculate
  15323. the factor by which the light is attenuated is
  15324.  
  15325.                                  2
  15326.   attenuation = --------------------------------------
  15327.                  1 + (d / FADE_DISTANCE) ^ FADE_POWER
  15328.  
  15329.  
  15330. with d being the distance the light has traveled.
  15331.  
  15332. Light fading functions for different fading powers.
  15333.  
  15334. You should note two important facts: First, for FADE_DISTANCEs larger than
  15335. one the light intensity at distances smaller than FADE_DISTANCE actually
  15336. increases. This is necessary to get the light source color if the distance
  15337. traveled equals the FADE_DISTANCE. Second, only light coming directly from
  15338. light sources is attenuated. Reflected or refracted light is not attenuated
  15339. by distance.
  15340.  
  15341. 7.5.6.8          Atmosphere Interaction
  15342.  
  15343. By default light sources will interact with an atmosphere added to the scene.
  15344. This behaviour can be switched off by using the atmosphere keyword inside the
  15345. light source statement.
  15346.  
  15347.   light_source {
  15348.     ...
  15349.     atmosphere off
  15350.   }
  15351.  
  15352.  
  15353. 7.5.6.9          Atmospheric Attenuation
  15354.  
  15355. Normally light coming from light sources is not influenced by fog or
  15356. atmosphere. This can be changed by turning the atmospheric attenuation for a
  15357. given light source on. All light coming from this light source will now be
  15358. diminished as it travels through the fog or atmosphere. This results in an
  15359. distance-based, exponential intensity falloff ruled by the used fog or
  15360. atmosphere. If there is no fog or atmosphere no change will be seen.
  15361.  
  15362. 7.5.7            Object Modifiers
  15363.  
  15364. A variety of modifiers may be attached to objects. Transformations such as
  15365. translate, rotate and scale have already been discussed. Textures are in a
  15366. section of their own below. Here are three other important modifiers:
  15367. clipped_by, bounded_by and no_shadow. Although the examples below use object
  15368. statements and object identifiers, these modifiers may be used on any type of
  15369. object such as sphere, box etc.
  15370.  
  15371. 7.5.7.1          Clipped_By
  15372.  
  15373. The clipped_by statement is technically an object modifier but it provides a
  15374. type of CSG similar to CSG intersection. You attach a clipping object like
  15375. this:
  15376.  
  15377.   object {
  15378.     My_Thing
  15379.     clipped_by{plane{y,0}}
  15380.   }
  15381.  
  15382.  
  15383. Every part of the object My_Thing that is inside the plane is retained while
  15384. the remaining part is clipped off and discarded. In an intersection object
  15385. the hole is closed off. With clipped_by it leaves an opening. For example the
  15386. following figure shows object A being clipped by object B.
  15387.  
  15388.    *       *
  15389.   *         *
  15390.  *           *
  15391. ***************
  15392. An object clipped by another object.
  15393.  
  15394. clipped_by may be used to slice off portions of any shape. In many cases it
  15395. will also result in faster rendering times than other methods of altering a
  15396. shape.
  15397.  
  15398. Often you will want to use the clipped_by and bounded_by options with the
  15399. same object. The following shortcut saves typing and uses less memory.
  15400.  
  15401.   object {
  15402.     My_Thing
  15403.     bounded_by { box { <0,0,0>, <1,1,1> } }
  15404.     clipped_by { bounded_by }
  15405.   }
  15406.  
  15407.  
  15408. 7.5.7.2          Bounded_By
  15409.  
  15410. The calculations necessary to test if a ray hits an object can be quite time
  15411. consuming. Each ray has to be tested against every object in the scene.
  15412. POV-Ray attempts so speed up the process by building a set of invisible
  15413. boxes, called bounding boxes, which cluster the objects together. This way a
  15414. ray that travels in one part of the scene doesn't have to be tested against
  15415. objects in another, far away part of the scene. When large a number of
  15416. objects are present the boxes are nested inside each other. POV-Ray can use
  15417. bounding boxes on any finite object and even some clipped or bounded
  15418. quadrics. However infinite objects (such as a planes, quartic, cubic and
  15419. poly) cannot be automatically bound. CSG objects are automatically bound if
  15420. they contain finite (and in some cases even infinite) objects. This works by
  15421. applying the CSG set operations to the bounding boxes of all objects used
  15422. inside the CSG object. For difference and intersection operations this will
  15423. hardly ever lead to an optimal bounding box. It's sometimes better (depending
  15424. on the complexity of the CSG object) to use a bounded_by statement with such
  15425. shapes.
  15426.  
  15427. Normally bounding shapes are not necessary but there are cases where they can
  15428. be used to speed up the rendering of complex objects. Bounding shapes tell
  15429. the ray-tracer that the object is totally enclosed by a simple shape. When
  15430. tracing rays, the ray is first tested against the simple bounding shape. If
  15431. it strikes the bounding shape the ray is further tested against the more
  15432. complicated object inside. Otherwise the entire complex shape is skipped,
  15433. which greatly speeds rendering.
  15434.  
  15435. To use bounding shapes, simply include the following lines in the declaration
  15436. of your object:
  15437.  
  15438.   bounded_by {
  15439.     object { ... }
  15440.   }
  15441.  
  15442.  
  15443. An example of a bounding shape:
  15444.  
  15445.   intersection {
  15446.     sphere { <0,0,0>, 2 }
  15447.     plane  { <0,1,0>, 0 }
  15448.     plane  { <1,0,0>, 0 }
  15449.     bounded_by { sphere { <0,0,0>, 2 } }
  15450.   }
  15451.  
  15452.  
  15453. The best bounding shape is a sphere or a box since these shapes are highly
  15454. optimized, although, any shape may be used. If the bounding shape is itself a
  15455. finite shape which responds to bounding slabs then the object which it
  15456. encloses will also be used in the slab system.
  15457.  
  15458. CSG shapes can benefit from bounding slabs without a bounded_by statement
  15459. however they may do so inefficiently in intersection, difference and merge.
  15460. In these three CSG types the automatic bound used covers all of the component
  15461. objects in their entirety. However the result of these intersections may
  15462. result in a smaller object. Compare the sizes of the illustrations for union
  15463. and intersection in the CSG section above. It is possible to draw a much
  15464. smaller box around the intersection of A and B than the union of A and B yet
  15465. the automatic bounds are the size of the union of A and B regardless of the
  15466. kind of CSG specified.
  15467.  
  15468. While it is almost always a good idea to manually add a bounded_by to
  15469. intersection, difference and merge, it is often best to not bound a union. If
  15470. a union has no bounded_by and no clipped_by POV-Ray can internally split
  15471. apart the components of a union and apply automatic bounding slabs to any of
  15472. its finite parts. Note that some utilities such as raw2pov may be able to
  15473. generate bounds more efficiently than POV-Ray's current system. However most
  15474. unions you create yourself can be easily bounded by the automatic system. For
  15475. technical reasons POV-Ray cannot split a merge object. It is probably best to
  15476. hand bound a merge, especially if it is very complex.
  15477.  
  15478. Note that if bounding shape is too small or positioned incorrectly it may
  15479. clip the object in undefined ways or the object may not appear at all. To do
  15480. true clipping, use clipped_by as explained above. Often you will want to use
  15481. the clipped_by and bounded_by options with the same object. The following
  15482. shortcut saves typing and uses less memory.
  15483.  
  15484.   object {
  15485.     My_Thing
  15486.     clipped_by{ box { <0,0,0>,<1,1,1 > }}
  15487.     bounded_by{ clipped_by }
  15488.   }
  15489.  
  15490.  
  15491. 7.5.7.3          Hollow
  15492.  
  15493. POV-Ray by default assumes that objects are made of a solid material that
  15494. completely fills the interior of an object. By adding the hollow keyword to
  15495. the object you can make it hollow. That is very useful if you want
  15496. atmospheric effects to exist inside an object. It is even required for
  15497. objects containing a halo (see "Halo" for details).
  15498.  
  15499. In order to get a hollow CSG object you just have to make the top level
  15500. object hollow. All children will assume the same hollow state except their
  15501. state is explicitly set. The following example will set both spheres inside
  15502. the union hollow
  15503.  
  15504.   union {
  15505.     sphere { -0.5*x, 1 }
  15506.     sphere {  0.5*x, 1 }
  15507.     hollow
  15508.   }
  15509.  
  15510.  
  15511. while the next example will only set the second sphere hollow because the
  15512. first sphere was explicitly set to be not hollow.
  15513.  
  15514.   union {
  15515.     sphere { -0.5*x, 1 hollow off }
  15516.     sphere {  0.5*x, 1 }
  15517.     hollow
  15518.   }
  15519.  
  15520.  
  15521. 7.5.7.4          No_Shadow
  15522.  
  15523. You may specify the no_shadow keyword in an object to make that object cast
  15524. no shadow. This is useful for special effects and for creating the illusion
  15525. that a light source actually is visible. This keyword was necessary in
  15526. earlier versions of POV-Ray which did not have the looks_like statement. Now
  15527. it is useful for creating things like laser beams or other unreal effects.
  15528.  
  15529. Simply attach the keyword as follows:
  15530.  
  15531.   object {
  15532.     My_Thing
  15533.     no_shadow
  15534.   }
  15535.  
  15536.  
  15537. 7.5.7.5          Sturm
  15538.  
  15539. Some of POV-Ray's objects allow you to choose between a fast but sometimes
  15540. inaccurate root solver and a slower but more accurate one. This is the case
  15541. for all objects that involve the solution of a cubic or quartic polynomial.
  15542. There are analytic mathematical solutions for those polynomials that can be
  15543. used.
  15544.  
  15545. Lower order polynomials are trivial to solve while higher order polynomials
  15546. require iterative algorithms to solve them. One of those algorithms is the
  15547. Sturmian root solver.
  15548.  
  15549. The following list shows all objects for which the Sturmian root solver can
  15550. be used.
  15551.  
  15552.   blob
  15553.   cubic
  15554.   lathe    (only with quadratic splines)
  15555.   poly
  15556.   prism    (only with cubic splines)
  15557.   quartic
  15558.   sor
  15559.  
  15560.  
  15561. 7.6              Textures
  15562.  
  15563. The texture describes what the object looks like, i. e. its material.
  15564. Textures are combinations of pigments, normals, finishes and halos. Pigment
  15565. is the color or pattern of colors inherent in the material. Normal is a
  15566. method of simulating various patterns of bumps, dents, ripples or waves by
  15567. modifying the surface normal vector. Finish describes the reflective and
  15568. refractive properties of a material. Halo simulates effects like clouds, fog,
  15569. fire etc. by using a density field defined inside the object.
  15570.  
  15571. A plain texture consists of a single pigment, an optional normal, a single
  15572. finish and optionally one or more halos. A special  texture combines two or
  15573. more textures using a pattern or blending function. Special textures may be
  15574. made quite complex by nesting patterns within patterns. At the innermost
  15575. levels however, they are made up from plain textures. Note that although we
  15576. call a plain texture plain it may be a very complex texture. The term plain
  15577. only means that it has a single pigment, normal, finish and halo.
  15578.  
  15579. The most complete form for defining a plain texture is as follows:
  15580.  
  15581.   texture {
  15582.     TEXTURE_IDENTIFIER
  15583.     pigment {...}
  15584.     normal {...}
  15585.     finish {...}
  15586.     halo {...}
  15587.     TRANSFORMATIONS
  15588.   }
  15589.  
  15590.  
  15591. Each of the items in a texture are optional but if they are present the
  15592. identifier must be first and the transformations must be last. The pigment,
  15593. normal and finish parameters modify any pigment, normal and finish already
  15594. specified in the TEXTURE_IDENTIFIER. Any halos are added to the already
  15595. existing halos. If no texture identifier is specified the pigment, normal and
  15596. finish statements modify the current default values and any halo is added to
  15597. the default halo, if any. TRANSFORMATIONs are translate, rotate, scale and
  15598. matrix statements. They should be specified last.
  15599.  
  15600. The sections below describe all of the options available in pigments,
  15601. normals, finishes and halos. Special textures are covered later.
  15602.  
  15603. 7.6.1            Pigment
  15604.  
  15605. The color or pattern of colors for an object is defined by a pigment
  15606. statement. All plain textures must have a pigment. If you do not specify one
  15607. the default pigment is used. A pigment statement is part of a texture
  15608. specification. However it can be tedious to use a texture statement just to
  15609. add a color to an object. Therefore you may attach a pigment directly to an
  15610. object without explicitly specifying that it as part of a texture. For
  15611. example:
  15612.  
  15613.   //this...                //can be shortened to this...
  15614.  
  15615.   object {                 object {
  15616.     My_Object                My_Object
  15617.     texture {                pigment {color Red}
  15618.       pigment {color Red}  }
  15619.     }
  15620.   }
  15621.  
  15622.  
  15623. The color you define is the way you want the object to look if fully
  15624. illuminated. You pick the basic color inherent in the object and POV-Ray
  15625. brightens or darkens it depending on the lighting in the scene. The parameter
  15626. is called pigment because we are defining the basic color the object actually
  15627. is rather than how it looks.
  15628.  
  15629. The most complete form for defining a pigment is as follows:
  15630.  
  15631.   pigment {
  15632.     PIGMENT_IDENTIFIER
  15633.     PATTERN_TYPE
  15634.     PIGMENT_MODIFIERS...
  15635.   }
  15636.  
  15637.  
  15638. Each of the items in a pigment are optional but if they are present, they
  15639. should be in the order shown above to insure that the results are as
  15640. expected. Any items after the PIGMENT_IDENTIFIER modify or override settings
  15641. given in the identifier. If no identifier is specified then the items modify
  15642. the pigment values in the current default texture. Valid PIGMENT_MODIFIERS
  15643. are color_map, pigment_map, image_map and quick_color statements as well as
  15644. any of the generic PATTERN_MODIFIERS such as translate, rotate, scale,
  15645. turbulence, wave shape and warp statements. Such modifiers apply only to the
  15646. pigment and not to other parts of the texture. Modifiers should be specified
  15647. last.
  15648.  
  15649. The various pattern types fall into roughly four categories. Each category is
  15650. discussed below. They are solid color, color list patterns, color mapped
  15651. patterns and image maps.
  15652.  
  15653. 7.6.1.1          Solid Color Pigments
  15654.  
  15655. The simplest type of pigment is a solid color. To specify a solid color you
  15656. simply put a color specification inside a pigment. For example:
  15657.  
  15658.   pigment {color Orange}
  15659.  
  15660.  
  15661. A color specification consists of the option keyword color followed by a
  15662. color identifier or by a specification of the amount of red, green, blue,
  15663. filtered and unfiltered transparency in the surface. See section "Specifying
  15664. Colors" for more details about colors. Any pattern modifiers used with a
  15665. solid color are ignored because there is no pattern to modify.
  15666.  
  15667. 7.6.1.2          Color List Pigments
  15668.  
  15669. There are three color list patterns: checker, hexagon and brick. The result
  15670. is a pattern of solid colors with distinct edges rather than a blending of
  15671. colors as with color mapped patterns. Each of these patterns is covered in
  15672. more detail in a later section. The syntax for each is:
  15673.  
  15674.   pigment { brick COLOR1, COLOR2 MODIFIERS ... }
  15675.   pigment { checker COLOR1, COLOR2 MODIFIERS ... }
  15676.   pigment { hexagon COLOR1, COLOR2, COLOR3 MODIFIERS ... }
  15677.  
  15678.  
  15679. Each COLORn is any valid color specification. There should be a comma between
  15680. each color or the color keyword should be used as a separator so that POV-Ray
  15681. can determine where each color specification starts and ends.
  15682.  
  15683. 7.6.1.3          Color Maps
  15684.  
  15685. Most of the color patterns do not use abrupt color changes of just two or
  15686. three colors like those in the brick, checker or hexagon patterns. They
  15687. instead use smooth transitions of many colors that gradually change from one
  15688. point to the next. The colors are defined in a pigment modifier called a
  15689. color map that describes how the pattern blends from one color to the next.
  15690.  
  15691. Each of the various pattern types available is in fact a mathematical
  15692. function that takes any x, y, z location and turns it into a number between
  15693. 0.0 and 1.0 inclusive. That number is used to specify what mix of colors to
  15694. use from the color map.
  15695.  
  15696. A color map is specified by...
  15697.  
  15698.   pigment{
  15699.     PATTERN_TYPE
  15700.     color_map {
  15701.       [ NUM_1 COLOR_1]
  15702.       [ NUM_2 COLOR_2]
  15703.       [ NUM_3 COLOR_3]
  15704.        ...
  15705.     }
  15706.     PIGMENT_MODIFIERS...
  15707.   }
  15708.  
  15709.  
  15710. Where NUM_1, NUM_2, ... are float values between 0.0 and 1.0 inclusive.
  15711. COLOR_1, COLOR_2, ... are color specifications. Note that the [] brackets are
  15712. part of the actual statement. They are not notational symbols denoting
  15713. optional parts. The brackets surround each entry in the color map. There may
  15714. be from 2 to 256 entries in the map. The alternate spelling colour_map may be
  15715. used.
  15716.  
  15717. For example
  15718.  
  15719.   sphere {
  15720.     <0,1,2>, 2
  15721.     pigment {
  15722.       gradient x       //this is the PATTERN_TYPE
  15723.       color_map {
  15724.         [0.1  color Red]
  15725.         [0.3  color Yellow]
  15726.         [0.6  color Blue]
  15727.         [0.6  color Green]
  15728.         [0.8  color Cyan]
  15729.       }
  15730.     }
  15731.   }
  15732.  
  15733.  
  15734. The pattern function is evaluated and the result is a value from 0.0 to 1.0.
  15735. If the value is less than the first entry (in this case 0.1) then the first
  15736. color (red) is used. Values from 0.1 to 0.3 use a blend of red and yellow
  15737. using linear interpolation of the two colors. Similarly values from 0.3 to
  15738. 0.6 blend from yellow to blue. Note that the 3rd and 4th entries both have
  15739. values of 0.6. This causes an immediate abrupt shift of color from blue to
  15740. green. Specifically a value that is less than 0.6 will be blue but exactly
  15741. equal to 0.6 will be green. Moving along, values from 0.6 to 0.8 will be a
  15742. blend of green and cyan. Finally any value greater than or equal to 0.8 will
  15743. be cyan.
  15744.  
  15745. If you want areas of unchanging color you simply specify the same color for
  15746. two adjacent entries. For example:
  15747.  
  15748.   color_map {
  15749.     [0.1  color Red]
  15750.     [0.3  color Yellow]
  15751.     [0.6  color Yellow]
  15752.     [0.8  color Green]
  15753.   }
  15754.  
  15755.  
  15756. In this case any value from 0.3 to 0.6 will be pure yellow.
  15757.  
  15758. The color_map keyword may be used with any pattern except brick, checker,
  15759. hexagon and image_map. You may declare and use color_map identifiers. For
  15760. example:
  15761.  
  15762.   #declare Rainbow_Colors=
  15763.     color_map {
  15764.       [0.0   color Magenta]
  15765.       [0.33  color Yellow]
  15766.       [0.67  color Cyan]
  15767.       [1.0   color Magenta]
  15768.     }
  15769.  
  15770.   object{My_Object
  15771.     pigment{
  15772.       gradient x
  15773.       color_map{Rainbow_Colors}
  15774.     }
  15775.   }
  15776.  
  15777.  
  15778. 7.6.1.4          Pigment Maps
  15779.  
  15780. In addition to specifying blended colors with a color map you may create a
  15781. blend of pigments using a pigment map. The syntax for a pigment map is
  15782. identical to a color map except you specify a pigment in each map entry (and
  15783. not a color).
  15784.  
  15785. A pigment map is specified by...
  15786.  
  15787.   pigment{
  15788.     PATTERN_TYPE
  15789.     pigment_map {
  15790.       [ NUM_1 PIGMENT_BODY_1]
  15791.       [ NUM_2 PIGMENT_BODY_2]
  15792.       [ NUM_3 PIGMENT_BODY_3]
  15793.        ...
  15794.     }
  15795.     PIGMENT_MODIFIERS...
  15796.   }
  15797.  
  15798.  
  15799. Where NUM_1, NUM_2, ... are float values between 0.0 and 1.0 inclusive. A
  15800. PIGMENT_BODY is anything that would normally appear inside a pigment
  15801. statement but the pigment keyword and {} braces are not needed. Note that the
  15802. [] brackets are part of the actual statement. They are not notational symbols
  15803. denoting optional parts. The brackets surround each entry in the map. There
  15804. may be from 2 to 256 entries in the map.
  15805.  
  15806. For example
  15807.  
  15808.   sphere {
  15809.     <0,1,2>, 2
  15810.     pigment {
  15811.       gradient x       //this is the PATTERN_TYPE
  15812.       pigment_map {
  15813.         [0.3 wood scale 0.2]
  15814.         [0.3 Jade]    //this is a pigment identifier
  15815.         [0.6 Jade]
  15816.         [0.9 marble turbulence 1]
  15817.       }
  15818.     }
  15819.   }
  15820.  
  15821.  
  15822. When the gradient x function returns values from 0.0 to 0.3 the scaled wood
  15823. pigment is used. From 0.3 to 0.6 the pigment identifier Jade is used. From
  15824. 0.6 up to 0.9 a blend of Jade and a turbulent marble is used. From 0.9 on up
  15825. only the turbulent marble is used.
  15826.  
  15827. Pigment maps may be nested to any level of complexity you desire. The
  15828. pigments in a map may have color maps or pigment maps or any type of pigment
  15829. you want. Any entry of a pigment map may be a solid color however if all
  15830. entries are solid colors you should use a color map which will render
  15831. slightly faster.
  15832.  
  15833. Entire pigments may also be used with the block patterns such as checker,
  15834. hexagon and brick. For example...
  15835.  
  15836.   pigment {
  15837.     checker
  15838.     pigment { Jade scale .8 }
  15839.     pigment { White_Marble scale .5 }
  15840.   }
  15841.  
  15842.  
  15843. Note that in the case of block patterns the pigment wrapping is required
  15844. around the pigment information.
  15845.  
  15846. A pigment map is also used with the average pigment type. See "Average" for
  15847. details.
  15848.  
  15849. You may not use pigment_map or individual pigments with an image_map. See
  15850. section "Texture Maps" for an alternative way to do this.
  15851.  
  15852. 7.6.1.5          Image Maps
  15853.  
  15854. When all else fails and none of the above pigment pattern types meets your
  15855. needs you can use an image map to wrap a 2-D bit-mapped image around your 3-D
  15856. objects.
  15857.  
  15858. 7.6.1.5.1        Specifying an Image Map
  15859.  
  15860. The syntax for an image map is...
  15861.  
  15862.   pigment {
  15863.     image_map {
  15864.       FILE_TYPE "filename"
  15865.       MODIFIERS...
  15866.     }
  15867.   }
  15868.  
  15869.  
  15870. Where FILE_TYPE is one of the following keywords gif, tga, iff, ppm, pgm, png
  15871. or sys. This is followed by the name of the file in quotes. Several optional
  15872. modifiers may follow the file specification. The modifiers are described
  15873. below. Note that earlier versions of POV-Ray allowed some modifiers before
  15874. the FILE_TYPE but that syntax is being phased out in favor of the syntax
  15875. described here.
  15876.  
  15877. Filenames specified in the image_map statements will be searched for in the
  15878. home (current) directory first and, if not found, will then be searched for
  15879. in directories specified by any -L (library path) options active. This would
  15880. facilitate keeping all your image maps files in a separate subdirectory and
  15881. giving an -L option on the command line to where your library of image maps
  15882. are.
  15883.  
  15884. By default, the image is mapped onto the x-y-plane. The image is projected
  15885. onto the object as though there were a slide projector somewhere in the
  15886. -z-direction. The image exactly fills the square area from (x,y) coordinates
  15887. (0,0) to (1,1) regardless of the image's original size in pixels. If you
  15888. would like to change this default you may translate, rotate or scale the
  15889. pigment or texture to map it onto the object's surface as desired.
  15890.  
  15891. In section "Checker" the checker pigment pattern is explained. The checks are
  15892. described as solid cubes of colored clay from which objects are carved. With
  15893. image maps you should imagine that each pixel is a long, thin, square,
  15894. colored rod that extends parallel to the z-axis. The image is made from rows
  15895. and columns of these rods bundled together and the object is then carved from
  15896. the bundle.
  15897.  
  15898. If you would like to change this default orientation you may translate,
  15899. rotate or scale the pigment or texture to map it onto the object's surface as
  15900. desired.
  15901.  
  15902. 7.6.1.5.2        The map_type Option
  15903.  
  15904. The default projection of the image onto the x-y-plane is called a planar map
  15905. type. This option may be changed by adding the map_type keyword followed by a
  15906. number specifying the way to wrap the image around the object.
  15907.  
  15908. A map_type 0 gives the default planar mapping already described.
  15909.  
  15910. A map_type 1 gives a spherical mapping. It assumes that the object is a
  15911. sphere of any size sitting at the origin. The y-axis is the north/south pole
  15912. of the spherical mapping. The top and bottom edges of the image just touch
  15913. the pole regardless of any scaling. The left edge of the image begins at the
  15914. positive x-axis and wraps the image around the sphere from west to east in a
  15915. -y-rotation. The image covers the sphere exactly once. The once keyword has
  15916. no meaning for this mapping type.
  15917.  
  15918. With map_type 2 you get a cylindrical mapping. It assumes that a cylinder of
  15919. any diameter lies along the y-axis. The image wraps around the cylinder just
  15920. like the spherical map but the image remains one unit tall from y=0 to y=1.
  15921. This band of color is repeated at all heights unless the once keyword is
  15922. applied.
  15923.  
  15924. Finally map_type 5 is a torus or donut shaped mapping. It assumes that a
  15925. torus of major radius one sits at the origin in the x-z-plane. The image is
  15926. wrapped around similar to spherical or cylindrical maps. However the top and
  15927. bottom edges of the map wrap over and under the torus where they meet each
  15928. other on the inner rim.
  15929.  
  15930. Types 3 and 4 are still under development.
  15931.  
  15932. Note that the map_type option may also be applied to bump_map and
  15933. material_map statements.
  15934.  
  15935. 7.6.1.5.3        The Filter and Transmit Bitmap Modifiers
  15936.  
  15937. To make all or part of an image map transparent you can specify filter and/or
  15938. transmit values for the color palette/registers of PNG, GIF or IFF pictures
  15939. (at least for the modes that use palettes). You can do this by adding the
  15940. keyword filter or transmit following the filename. The keyword is followed by
  15941. two numbers. The first number is the palette number value and the second is
  15942. the amount of transparency. The values should be separated by a comma. For
  15943. example:
  15944.  
  15945.   image_map {
  15946.     gif "mypic.gif"
  15947.     filter   0, 0.5 // Make color 0 50% filtered transparent
  15948.     filter   5, 1.0 // Make color 5 100% filtered transparent
  15949.     transmit 8, 0.3 // Make color 8 30% non-filtered transparent
  15950.   }
  15951.  
  15952.  
  15953. You can give the entire image a filter or transmit value using filter all
  15954. VALUE or transmit all VALUE. For example:
  15955.  
  15956.   image_map {
  15957.     gif "stnglass.gif"
  15958.     filter all 0.9
  15959.   }
  15960.  
  15961.  
  15962. Note that early versions of POV-Ray used the keyword alpha to specify
  15963. filtered transparency however that word is often used to describe
  15964. non-filtered transparency. For this reason alpha is no longer used.
  15965.  
  15966. See section "Specifying Colors" for details on the differences between
  15967. filtered and non-filtered transparency.
  15968.  
  15969. 7.6.1.5.4        Using the Alpha Channel
  15970.  
  15971. Another way to specify non-filtered transmit transparency in an image map is
  15972. by using the alpha channel.
  15973.  
  15974. PNG allows you to store a different transparency for each color index in the
  15975. PNG file, if desired. If your paint programs support this feature of PNG you
  15976. can do the transparency editing within your paint program rather than
  15977. specifying transmit values for each color in the POV file. Since PNG and TGA
  15978. image formats can also store full alpha channel (transparency) information
  15979. you can generate image maps that have transparency which isn't dependent on
  15980. the color of a pixel but rather its location in the image.
  15981.  
  15982. Although POV uses transmit 0.0 to specify no transparency and 1.0 to specify
  15983. full transparency, the alpha data ranges from 0 to 255 in the opposite
  15984. direction. Alpha data 0 means the same as transmit 1.0 and alpha data 255
  15985. produces transmit 0.0.
  15986.  
  15987. 7.6.1.6          Quick Color
  15988.  
  15989. When developing POV-Ray scenes its often useful to do low quality test runs
  15990. that render faster. The +Q command line switch can be used to turn off some
  15991. time consuming color pattern and lighting calculations to speed things up.
  15992. However all settings of +Q5 or lower turns off pigment calculations and
  15993. creates gray objects.
  15994.  
  15995. By adding a quick_color to a pigment you tell POV-Ray what solid color to use
  15996. for quick renders instead of a patterned pigment. For example:
  15997.  
  15998.   pigment {
  15999.     gradient x
  16000.     color_map{
  16001.       [0.0 color Yellow]
  16002.       [0.3 color Cyan]
  16003.       [0.6 color Magenta]
  16004.       [1.0 color Cyan]
  16005.     }
  16006.     turbulence 0.5
  16007.     lambda 1.5
  16008.     omega 0.75
  16009.     octaves 8
  16010.     quick_color Neon_Pink
  16011.   }
  16012.  
  16013.  
  16014. This tells POV-Ray to use solid Neon_Pink for test runs at quality +Q5 or
  16015. lower but to use the turbulent gradient pattern for rendering at +Q6 and
  16016. higher.
  16017.  
  16018. Note that solid color pigments such as
  16019.  
  16020.   pigment {color Magenta}
  16021.  
  16022.  
  16023. automatically set the quick_color to that value. You may override this if you
  16024. want. Suppose you have 10 spheres on the screen and all are yellow. If you
  16025. want to identify them individually you could give each a different
  16026. quick_color like this:
  16027.  
  16028.   sphere {
  16029.     <1,2,3>,4
  16030.     pigment { color Yellow  quick_color Red }
  16031.   }
  16032.  
  16033.   sphere {
  16034.     <-1,-2,-3>,4
  16035.     pigment { color Yellow  quick_color Blue }
  16036.   }
  16037.  
  16038.  
  16039. and so on. At +Q6 or higher they will all be yellow but at +Q5 or lower each
  16040. would be different colors so you could identify them.
  16041.  
  16042. 7.6.2            Normal
  16043.  
  16044. Ray-tracing is known for the dramatic way it depicts reflection, refraction
  16045. and lighting effects. Much of our perception depends on the reflective
  16046. properties of an object. Ray tracing can exploit this by playing tricks on
  16047. our perception to make us see complex details that aren't really there.
  16048.  
  16049. Suppose you wanted a very bumpy surface on the object. It would be very
  16050. difficult to mathematically model lots of bumps. We can however simulate the
  16051. way bumps look by altering the way light reflects off of the surface.
  16052. Reflection calculations depend on a vector called a surface normal vector.
  16053. This is a vector which points away from the surface and is perpendicular to
  16054. it. By artificially modifying (or perturbing) this normal vector you can
  16055. simulate bumps.
  16056.  
  16057. The normal statement is the part of a texture which defines the pattern of
  16058. normal perturbations to be applied to an object. Like the pigment statement,
  16059. you can omit the surrounding texture block to save typing. Do not forget
  16060. however that there is a texture implied. For example...
  16061.  
  16062.   //this...                    //can be shortened to this...
  16063.  
  16064.   object {                     object {
  16065.     My_Object                    My_Object
  16066.     texture {                    pigment {color Purple}
  16067.       pigment {color Purple}     normal {bumps 0.3}
  16068.       normal {bumps 0.3}       }
  16069.     }
  16070.   }
  16071.  
  16072.  
  16073. Note that attaching a normal pattern does not really modify the surface. It
  16074. only affects the way light reflects or refracts at the surface so that it
  16075. looks bumpy.
  16076.  
  16077. The most complete form for defining a normal is as follows:
  16078.  
  16079.   normal {
  16080.     NORMAL_IDENTIFIER
  16081.     PATTERN_TYPE FloatValue
  16082.     NORMAL_MODIFIERS
  16083.     TRANSFORMATIONS...
  16084.   }
  16085.  
  16086.  
  16087. Each of the items in a normal are optional but if they are present they
  16088. should be in the order shown above to insure that the results are as
  16089. expected. Any items after the NORMAL_IDENTIFIER modify or override settings
  16090. given in the identifier. If no identifier is specified then the items modify
  16091. the normal values in the current default texture. The PATTERN_TYPE may
  16092. optionally be followed by a float value that controls the apparent depth of
  16093. the bumps. Typical values range from 0.0 to 1.0 but any value may be used.
  16094. Negative values invert the pattern. The default value if none is specified is
  16095. 0.5.
  16096.  
  16097. Valid NORMAL_MODIFIERS are slope_map, normal_map, bump_map and bump_size
  16098. statements as well as any of the generic PATTERN_MODIFIERS such as translate,
  16099. rotate, scale, turbulence, wave shape and warp statements. Such modifiers
  16100. apply only to the normal and not to other parts of the texture. Modifiers
  16101. should be specified last.
  16102.  
  16103. There are three basic types of NORMAL_PATTERN_TYPEs. They are pattern
  16104. normals, specialized normals and bump maps. They differ in the types of
  16105. modifiers you may use with them. Originally POV-Ray had some patterns which
  16106. were exclusively used for pigments while others were exclusively used for
  16107. normals. Since POV-Ray 3.0 you can use any pattern for either pigments or
  16108. normals. For example it is now valid to use ripples as a pigment or wood as a
  16109. normal type. The patterns bumps, dents, ripples, waves, wrinkles and bump_map
  16110. were once exclusively normal patterns which could not be used as pigments.
  16111. Because these six types use specialized normal modification calculations they
  16112. cannot have slope_map, normal_map or wave shape modifiers. All other normal
  16113. pattern types may use them.
  16114.  
  16115. 7.6.2.1          Slope Maps
  16116.  
  16117. A slope map is a normal pattern modifier which gives the user a great deal of
  16118. control over the exact shape of the bumpy features. It is best illustrated
  16119. with a gradient normal pattern. Suppose you have...
  16120.  
  16121.   plane{ z, 0
  16122.     pigment{ White }
  16123.     normal { gradient x }
  16124.   }
  16125.  
  16126.  
  16127. This gives a ramp wave pattern that looks like small linear ramps that climb
  16128. from the points at x=0 to x=1 and then abruptly drops to 0 again to repeat
  16129. the ramp from x=1 to x=2. A slope map turns this simple linear ramp into
  16130. almost any wave shape you want. The syntax is as follows...
  16131.  
  16132.   normal{
  16133.     PATTERN_TYPE Value
  16134.     slope_map {
  16135.       [ NUM_1 POINT_SLOPE_1]
  16136.       [ NUM_2 POINT_SLOPE_2]
  16137.       [ NUM_3 POINT_SLOPE_3]
  16138.        ...
  16139.     }
  16140.     NORMAL_MODIFIERS...
  16141.   }
  16142.  
  16143.  
  16144. Note that the [] brackets are part of the actual statement. They are not
  16145. notational symbols denoting optional parts. The brackets surround each entry
  16146. in the slope map. There may be from 2 to 256 entries in the map.
  16147.  
  16148. The NUM_1, NUM_2, ... are float values between 0.0 and 1.0 inclusive.
  16149. POINT_SLOPE_1, POINT_SLOPE_2, ... are 2 component vectors such as <0,1> where
  16150. the first value represents the apparent height of the wave and the second
  16151. value represents the slope of the wave at that point. The height should range
  16152. between 0.0 and 1.0 but any value could be used.
  16153.  
  16154. The slope value is the change in height per unit of distance. For example a
  16155. slope of zero means flat, a slope of 1.0 means slope upwards at a 45 degree
  16156. angle and a slope of -1 means slope down at 45 degrees. Theoretically a slope
  16157. straight up would have infinite slope. In practice, slope values should be
  16158. kept in the range -3.0 to +3.0. Keep in mind that this is only the visually
  16159. apparent slope. A normal does not actually change the surface.
  16160.  
  16161. For example here is how to make the ramp slope up for the first half and back
  16162. down on the second half creating a triangle wave with a sharp peak in the
  16163. center.
  16164.  
  16165.   normal {
  16166.     gradient x       // this is the PATTERN_TYPE
  16167.     slope_map {
  16168.       [0   <0, 1>]   // start at bottom and slope up
  16169.       [0.5 <1, 1>]   // halfway through reach top still climbing
  16170.       [0.5 <1,-1>]   // abruptly slope down
  16171.       [1   <0,-1>]   // finish on down slope at bottom
  16172.     }
  16173.   }
  16174.  
  16175.  
  16176. The pattern function is evaluated and the result is a value from 0.0 to 1.0.
  16177. The first entry says that at x=0 the apparent height is 0 and the slope is 1.
  16178. At x=0.5 we are at height 1 and slope is still up at 1. The third entry also
  16179. specifies that at x=0.5 (actually at some tiny fraction above 0.5) we have
  16180. height 1 but slope -1 which is downwards. Finally at x=1 we are at height 0
  16181. again and still sloping down with slope -1.
  16182.  
  16183. Although this example connects the points using straight lines the shape is
  16184. actually a cubic spline. This example creates a smooth sine wave.
  16185.  
  16186.   normal {
  16187.     gradient x          // this is the PATTERN_TYPE
  16188.     slope_map {
  16189.       [0    <0.5, 1>]   // start in middle and slope up
  16190.       [0.25 <1.0, 0>]   // flat slope at top of wave
  16191.       [0.5  <0.5,-1>]   // slope down at mid point
  16192.       [0.75 <0.0, 0>]   // flat slope at bottom
  16193.       [1    <0.5, 1>]   // finish in middle and slope up
  16194.     }
  16195.   }
  16196.  
  16197.  
  16198. This example starts at height 0.5 sloping up at slope 1. At a fourth of the
  16199. way through we are at the top of the curve at height 1 with slope 0 which is
  16200. flat. The space between these two is a gentle curve because the start and end
  16201. slopes are different. At half way we are at half height sloping down to
  16202. bottom out at 3/4ths. By the end we are climbing at slope 1 again to complete
  16203. the cycle. There are more examples in slopemap.pov in the sample scenes.
  16204.  
  16205. A slope_map may be used with any pattern except brick, checker, hexagon,
  16206. bumps, dents, ripples, waves, wrinkles and bump_map.
  16207.  
  16208. You may declare and use slope map identifiers. For example:
  16209.  
  16210.   #declare Fancy_Wave =
  16211.     slope_map {       // Now let's get fancy
  16212.       [0.0  <0, 1>]   // Do tiny triangle here
  16213.       [0.2  <1, 1>]   //  down
  16214.       [0.2  <1,-1>]   //     to
  16215.       [0.4  <0,-1>]   //       here.
  16216.       [0.4  <0, 0>]   // Flat area
  16217.       [0.5  <0, 0>]   //   through here.
  16218.       [0.5  <1, 0>]   // Square wave leading edge
  16219.       [0.6  <1, 0>]   //   trailing edge
  16220.       [0.6  <0, 0>]   // Flat again
  16221.       [0.7  <0, 0>]   //   through here.
  16222.       [0.7  <0, 3>]   // Start scallop
  16223.       [0.8  <1, 0>]   //   flat on top
  16224.       [0.9  <0,-3>]   //     finish here.
  16225.       [0.9  <0, 0>]   // Flat remaining through 1.0
  16226.     }
  16227.  
  16228.   object{ My_Object
  16229.     pigment { White }
  16230.     normal {
  16231.       wood
  16232.       slope_map { Fancy_Wave }
  16233.     }
  16234.   }
  16235.  
  16236.  
  16237. 7.6.2.2          Normal Maps
  16238.  
  16239. Most of the time you will apply single normal pattern to an entire surface
  16240. but you may also create a pattern or blend of normals using a normal map. The
  16241. syntax for a normal map is identical to a pigment map except you specify a
  16242. normal in each map entry.
  16243.  
  16244. A normal map is specified by...
  16245.  
  16246.   normal{
  16247.     PATTERN_TYPE
  16248.     normal_map {
  16249.       [ NUM_1 NORMAL_BODY_1]
  16250.       [ NUM_2 NORMAL_BODY_2]
  16251.       [ NUM_3 NORMAL_BODY_3]
  16252.        ...
  16253.     }
  16254.     NORMAL_MODIFIERS...
  16255.   }
  16256.  
  16257.  
  16258. Where NUM_1, NUM_2, ... are float values between 0.0 and 1.0 inclusive. A
  16259. NORMAL_BODY is anything that would normally appear inside a normal statement
  16260. but the normal keyword and {} braces are not needed. Note that the []
  16261. brackets are part of the actual statement. They are not notational symbols
  16262. denoting optional parts. The brackets surround each entry in the map. There
  16263. may be from 2 to 256 entries in the map.
  16264.  
  16265. For example
  16266.  
  16267.   normal {
  16268.     gradient x       //this is the PATTERN_TYPE
  16269.     normal_map {
  16270.       [0.3  bumps scale 2]
  16271.       [0.3  dents]
  16272.       [0.6  dents]
  16273.       [0.9  marble turbulence 1]
  16274.     }
  16275.   }
  16276.  
  16277.  
  16278. When the gradient x function returns values from 0.0 to 0.3 then the scaled
  16279. bumps normal is used. From 0.3 to 0.6 dents are From 0.6 up to 0.9 a blend of
  16280. dents and a turbulent marble is used. From 0.9 on up only the turbulent
  16281. marble is used.
  16282.  
  16283. Normal maps may be nested to any level of complexity you desire. The normals
  16284. in a map may have slope maps or normal maps or any type of normal you want.
  16285.  
  16286. A normal map is also used with the average normal type. See "Average" for
  16287. details.
  16288.  
  16289. Entire normals may also be used with the block patterns such as checker,
  16290. hexagon and brick. For example...
  16291.  
  16292.   normal {
  16293.     checker
  16294.       normal { gradient x scale .2 }
  16295.       normal { gradient y scale .2 }
  16296.     }
  16297.   }
  16298.  
  16299.  
  16300. Note that in the case of block patterns the normal wrapping is required
  16301. around the normal information.
  16302.  
  16303. You may not use normal_map or individual normals with a bump_map. See section
  16304. "Texture Maps" for an alternative way to do this.
  16305.  
  16306. 7.6.2.3          Bump Maps
  16307.  
  16308. When all else fails and none of the above normal pattern types meets your
  16309. needs you can use a bump map to wrap a 2-D bit-mapped bump pattern around
  16310. your 3-D objects.
  16311.  
  16312. Instead of placing the color of the image on the shape like an image map a
  16313. bump map perturbs the surface normal based on the color of the image at that
  16314. point. The result looks like the image has been embossed into the surface. By
  16315. default, a bump map uses the brightness of the actual color of the pixel.
  16316. Colors are converted to gray scale internally before calculating height.
  16317. Black is a low spot, white is a high spot. The image's index values may be
  16318. used instead (see section "Use_Index and Use_Color" below).
  16319.  
  16320. 7.6.2.3.1        Specifying a Bump Map
  16321.  
  16322. The syntax for bump_map is...
  16323.  
  16324.   normal {
  16325.     bump_map {
  16326.       FILE_TYPE "filename"
  16327.       BITMAP_MODIFIERS...
  16328.     }
  16329.     NORMAL_MODIFIERS...
  16330.   }
  16331.  
  16332.  
  16333. Where FILE_TYPE is one of the following keywords gif, tga, iff, ppm, pgm, png
  16334. or sys. This is followed by the name of the file using any valid string
  16335. expression. Several optional modifiers may follow the file specification. The
  16336. modifiers are described below. Note that earlier versions of POV-Ray allowed
  16337. some modifiers before the FILE_TYPE but that syntax is being phased out in
  16338. favor of the syntax described here.
  16339.  
  16340. Filenames specified in the bump_map statement will be searched for in the
  16341. home (current) directory first and, if not found, will then be searched for
  16342. in directories specified by any +L switches or Library_Path options. This
  16343. would facilitate keeping all your bump maps files in a separate subdirectory,
  16344. and specifying a library path to them. Note that any operating system default
  16345. paths are not searched unless you also specify them as a Library_Path.
  16346.  
  16347. By default, the bump pattern is mapped onto the x-y-plane. The bumps are
  16348. projected onto the object as though there were a slide projector somewhere in
  16349. the -z-direction. The bump pattern exactly fills the square area from (x,y)
  16350. coordinates (0,0) to (1,1) regardless of the bitmap's original size in
  16351. pixels. If you would like to change this default, you may translate, rotate
  16352. or scale the normal or texture to map it onto the object's surface as
  16353. desired.
  16354.  
  16355. The file name is optionally followed by one or more BITMAP_MODIFIERS. The
  16356. bump_size, use_color and use_index modifiers are specific to bump maps and
  16357. are discussed in the following sections. See section "Bitmap Modifiers" for
  16358. other general bitmap modifiers.
  16359.  
  16360. After a bump_map statement but still inside the normal statement you may
  16361. apply any legal normal modifiers except slope_map and pattern wave forms.
  16362.  
  16363. 7.6.2.3.2        Bump_Size
  16364.  
  16365. The relative bump size can be scaled using the bump_size modifier. The bump
  16366. size number can be any number other than 0 but typical values are from about
  16367. 0.1 to as high as 4.0 or 5.0.
  16368.  
  16369.   normal {
  16370.     bump_map {
  16371.       gif "stuff.gif"
  16372.       bump_size 5.0
  16373.     }
  16374.   }
  16375.  
  16376.  
  16377. Originally bump_size could only be used inside a bump map but it can now be
  16378. used with any normal. Typically it is used to override a previously defined
  16379. size. For example:
  16380.  
  16381.   normal {
  16382.     My_Normal   //this is a previously defined normal identifier
  16383.     bump_size 2.0
  16384.   }
  16385.  
  16386.  
  16387. 7.6.2.3.3        Use_Index and Use_Color
  16388.  
  16389. Usually the bump map converts the color of the pixel in the map to a gray
  16390. scale intensity value in the range 0.0 to 1.0 and calculates the bumps based
  16391. on that value. If you specify use_index, the bump map uses the color's
  16392. palette number to compute as the height of the bump at that point. So, color
  16393. number 0 would be low and color number 255 would be high (if the image has
  16394. 256 palette entries). The actual color of the pixels doesn't matter when
  16395. using the index. This option is only available on palette based formats. The
  16396. use_color keyword may be specified to explicitly note that the color methods
  16397. should be used instead. The alternate spelling use_colour is also valid.
  16398. These modifiers may only be used inside the bump_map statement.
  16399.  
  16400. 7.6.3            Finish
  16401.  
  16402. The finish properties of a surface can greatly affect its appearance. How
  16403. does light reflect? What happens when light passes through? What kind of
  16404. highlights are visible. To answer these questions you need a finish
  16405. statement.
  16406.  
  16407. The finish statement is the part of a texture which defines the various
  16408. finish properties to be applied to an object. Like the pigment or normal
  16409. statement you can omit the surrounding texture block to save typing. Do not
  16410. forget however that there is a texture implied. For example...
  16411.  
  16412.   this...                            can be shortened to this...
  16413.  
  16414.   object {                           object {
  16415.     My_Object                          My_Object
  16416.     texture {                          pigment {color Purple}
  16417.       pigment {color Purple}           finish {phong 0.3}
  16418.       finish {phong 0.3}             }
  16419.     }
  16420.   }
  16421.  
  16422.  
  16423. The most complete form for defining a finish is as follows:
  16424.  
  16425.   finish {
  16426.     FINISH_IDENTIFIER
  16427.     [ ambient COLOR ]
  16428.     [ diffuse FLOAT ]
  16429.     [ brilliance FLOAT ]
  16430.     [ phong FLOAT ]
  16431.     [ phong_size FLOAT ]
  16432.     [ specular FLOAT ]
  16433.     [ roughness FLOAT ]
  16434.     [ metallic [ FLOAT ] ]
  16435.     [ reflection COLOR ]
  16436.     [ refraction FLOAT ]
  16437.     [ ior FLOAT ]
  16438.     [ caustics FLOAT ]
  16439.     [ fade_distance FLOAT ]
  16440.     [ fade_power FLOAT ]
  16441.     [ irid { thickness FLOAT turbulence VECTOR } ]
  16442.     [ crand FLOAT ]
  16443.   }
  16444.  
  16445.  
  16446. The FINISH_IDENTIFIER is optional but should proceed all other items. Any
  16447. items after the FINISH_IDENTIFIER modify or override settings given in the
  16448. IDENTIFIER. If no identifier is specified then the items modify the finish
  16449. values in the current default texture. Note that transformations are not
  16450. allowed inside a finish because finish items cover the entire surface
  16451. uniformly.
  16452.  
  16453. 7.6.3.1          Ambient
  16454.  
  16455. The light you see in dark shadowed areas comes from diffuse reflection off of
  16456. other objects. This light cannot be directly modeled using ray-tracing.
  16457. However we can use a trick called ambient lighting to simulate the light
  16458. inside a shadowed area.
  16459.  
  16460. Ambient light is light that is scattered everywhere in the room. It bounces
  16461. all over the place and manages to light objects up a bit even where no light
  16462. is directly shining. Computing real ambient light would take far too much
  16463. time, so we simulate ambient light by adding a small amount of white light to
  16464. each texture whether or not a light is actually shining on that texture.
  16465.  
  16466. This means that the portions of a shape that are completely in shadow will
  16467. still have a little bit of their surface color. It's almost as if the texture
  16468. glows, though the ambient light in a texture only affects the shape it is
  16469. used on.
  16470.  
  16471. Usually a single float value is specified even though the syntax calls for a
  16472. color. For example a float value of 0.3 gets promoted to the full color
  16473. vector <0.3,0.3,0.3,0.3,0.3> which is acceptable because only the red, green
  16474. and blue parts are used.
  16475.  
  16476. The default value is very little ambient light (0.1). The value can range
  16477. from 0.0 to 1.0. Ambient light affects both shadowed and non-shadowed areas
  16478. so if you turn up the ambient value you may want to turn down the diffuse
  16479. value.
  16480.  
  16481. Note that this method doesn't account for the color of surrounding objects.
  16482. If you walk into a room that has red walls, floor and ceiling then your white
  16483. clothing will look pink from the reflected light. POV-Ray's ambient shortcut
  16484. doesn't account for this. There is also no way to model specular reflected
  16485. indirect illumination such as the flashlight shining in a mirror.
  16486.  
  16487. You may color the ambient light using one of two methods. You may specify a
  16488. color rather than a float after the ambient keyword in each finish statement.
  16489. For example
  16490.  
  16491.    finish { ambient rgb <0.3,0.1,0.1> } //a pink ambient
  16492.  
  16493.  
  16494. You may also specify the overall ambient light source used when calculating
  16495. the ambient lighting of an object using the global ambient_light setting. The
  16496. formula is given by
  16497.  
  16498.    AMBIENT = FINISH_AMBIENT * GLOBAL_AMBIENT_LIGHT_SOURCE
  16499.  
  16500.  
  16501. 7.6.3.2          Diffuse Reflection Items
  16502.  
  16503. When light reflects off of a surface the laws of physics say that it should
  16504. leave the surface at the exact same angle it came in. This is similar to the
  16505. way a billiard ball bounces off a bumper of a pool table. This perfect
  16506. reflection is called specular reflection. However only very smooth polished
  16507. surfaces reflect light in this way. Most of the time, light reflects and is
  16508. scattered in all directions by the roughness of the surface. This scattering
  16509. is called diffuse reflection because the light diffuses or spreads in a
  16510. variety of directions. It accounts for the majority of the reflected light we
  16511. see.
  16512.  
  16513. POV-Ray and most other ray-tracers can only simulate directly one of these
  16514. three types of illumination. That is the light which comes directly from
  16515. actual light sources. Light coming from other objects such as mirrors via
  16516. specular reflection (shine a flashlight onto a mirror for example). And last
  16517. not least light coming from other objects via diffuse reflections (look at
  16518. some dark area under a desk or in a corner: even though a lamp may not
  16519. directly illuminate that spot you can still see a little bit because light
  16520. comes from diffuse reflection off of nearby objects).
  16521.  
  16522. 7.6.3.2.1        Diffuse
  16523.  
  16524. The keyword diffuse is used in a finish statement to control how much of the
  16525. light coming directly from any light sources is reflected via diffuse
  16526. reflection. For example
  16527.  
  16528.   finish {diffuse 0.7}
  16529.  
  16530.  
  16531. means that 70% of the light seen comes from direct illumination from light
  16532. sources. The default value is diffuse 0.6.
  16533.  
  16534. 7.6.3.2.2        Brilliance
  16535.  
  16536. The amount of direct light that diffuses from an object depends upon the
  16537. angle at which it hits the surface. When light hits at a shallow angle it
  16538. illuminates less. When it is directly above a surface it illuminates more.
  16539. The brilliance keyword can be used in a finish statement to vary the way
  16540. light falls off depending upon the angle of incidence. This controls the
  16541. tightness of the basic diffuse illumination on objects and slightly adjusts
  16542. the appearance of surface shininess. Objects may appear more metallic by
  16543. increasing their brilliance. The default value is 1.0. Higher values from to
  16544. about 10.0 cause the light to fall off less at medium to low angles. There
  16545. are no limits to the brilliance value. Experiment to see what works best for
  16546. a particular situation. This is best used in concert with highlighting.
  16547.  
  16548. 7.6.3.2.3        Crand Graininess
  16549.  
  16550. Very rough surfaces, such as concrete or sand, exhibit a dark graininess in
  16551. their apparent color. This is caused by the shadows of the pits or holes in
  16552. the surface. The crand keyword can be added to cause a minor random darkening
  16553. in the diffuse reflection of direct illumination. Typical values range from
  16554. crand 0.01 to crand 0.5 or higher. The default value is 0. For example:
  16555.  
  16556.   finish { crand 0.05 }
  16557.  
  16558.  
  16559. The grain or noise introduced by this feature is applied on a pixel-by-pixel
  16560. basis. This means that it will look the same on far away objects as on close
  16561. objects. The effect also looks different depending upon the resolution you
  16562. are using for the rendering. For these reasons it is not a very accurate way
  16563. to model the rough surface effect but some objects still look better with a
  16564. little crand thrown in.
  16565.  
  16566. Note that this should not be used when rendering animations. This is the one
  16567. of a few truly random features in POV-Ray and will produce an annoying
  16568. flicker of flying pixels on any textures animated with a crand value.
  16569.  
  16570. 7.6.3.3          Highlights
  16571.  
  16572. Highlights are the bright spots that appear when a light source reflects off
  16573. of a smooth object. They are a blend of specular reflection and diffuse
  16574. reflection. They are specular-like because they depend upon viewing angle and
  16575. illumination angle. However they are diffuse-like because some scattering
  16576. occurs. In order to exactly model a highlight you would have to calculate
  16577. specular reflection off of thousands of microscopic bumps called micro
  16578. facets. The more that micro facets are facing the viewer the shinier the
  16579. object appears and the tighter the highlights become. POV-Ray uses two
  16580. different models to simulate highlights without calculating micro facets.
  16581. They are the specular and Phong models.
  16582.  
  16583. Note that specular and Phong highlights are not mutually exclusive. It is
  16584. possible to specify both and they will both take effect. Normally, however,
  16585. you will only specify one or the other.
  16586.  
  16587. 7.6.3.3.1        Phong Highlights
  16588.  
  16589. The phong keyword controls the amount of Phong highlighting on the object. It
  16590. causes bright shiny spots on the object that are the color of the light
  16591. source being reflected.
  16592.  
  16593. The Phong method measures the average of the facets facing in the mirror
  16594. direction from the light sources to the viewer.
  16595.  
  16596. Phong's value is typically from 0.0 to 1.0, where 1.0 causes complete
  16597. saturation to the light source's color at the brightest area (center) of the
  16598. highlight. The default phong 0.0 gives no highlight.
  16599.  
  16600. The size of the highlight spot is defined by the phong_size value. The larger
  16601. the phong size the tighter, or smaller, the highlight and the shinier the
  16602. appearance. The smaller the phong size the looser, or larger, the highlight
  16603. and the less glossy the appearance.
  16604.  
  16605. Typical values range from 1.0 (very dull) to 250 (highly polished) though any
  16606. values may be used. Default phong size is 40 (plastic) if phong_size is not
  16607. specified. For example:
  16608.  
  16609.   finish { phong 0.9 phong_size 60 }
  16610.  
  16611.  
  16612. 7.6.3.3.2        Specular Highlight
  16613.  
  16614. A specular highlight is very similar to Phong highlighting but it uses
  16615. slightly different model. The specular model more closely resembles real
  16616. specular reflection and provides a more credible spreading of the highlights
  16617. occurring near the object horizons.
  16618.  
  16619. The specular value is typically from 0.0 to 1.0, where 1.0 causes complete
  16620. saturation to the light source's color at the brightest area (center) of the
  16621. highlight. The default specular 0.0 gives no highlight.
  16622.  
  16623. The size of the spot is defined by the value given for roughness. Typical
  16624. values range from 1.0 (very rough - large highlight) to 0.0005 (very smooth -
  16625. small highlight). The default value, if roughness is not specified, is 0.05
  16626. (plastic).
  16627.  
  16628. It is possible to specify wrong values for roughness that will generate an
  16629. error when you try to render the file. Don't use 0 and if you get errors
  16630. check to see if you are using a very, very small roughness value that may be
  16631. causing the error. For example:
  16632.  
  16633.   finish {specular 0.9  roughness 0.02}
  16634.  
  16635.  
  16636. 7.6.3.3.3        Metallic Highlight Modifier
  16637.  
  16638. The keyword metallic may be used with Phong or specular highlights. This
  16639. keyword indicates that the color of the highlights will be calculated by an
  16640. empirical function that models the reflectivity of metallic surfaces.
  16641.  
  16642. White light reflected specularly from a metallic surface takes the color of
  16643. the surface, except then the incidence angle approaches 90 degrees, where it
  16644. becomes white again.
  16645.  
  16646. The metallic keyword may be follow by a numeric value to specify the
  16647. influence the above effect has (the default value is one). For example:
  16648.  
  16649.   finish {
  16650.     phong 0.9
  16651.     phong_size 60
  16652.     metallic
  16653.   }
  16654.  
  16655.  
  16656. 7.6.3.4          Specular Reflection
  16657.  
  16658. When light does not diffuse and it does reflect at the same angle as it hits
  16659. an object, it is called specular reflection. Such mirror-like reflection is
  16660. controlled by the reflection keyword in a finish statement. For example:
  16661.  
  16662.   finish { reflection 1.0 ambient 0 diffuse 0 }
  16663.  
  16664.  
  16665. This gives the object a mirrored finish. It will reflect all other elements
  16666. in the scene. Usually a single float value is specified after the keyword
  16667. even though the syntax calls for a color. For example a float value of 0.3
  16668. gets promoted to the full color vector < 0.3,0.3,0.3,0.3,0.3> which is
  16669. acceptable because only the red, green and blue parts are used.
  16670.  
  16671. The value can range from 0.0 to 1.0. By default there is no reflection.
  16672.  
  16673. Adding reflection to a texture makes it take longer to render because an
  16674. additional ray must be traced. The reflected light may be tinted by
  16675. specifying a color rather than a float. For example
  16676.  
  16677.    finish { reflection rgb <1,0,0> }
  16678.  
  16679.  
  16680. gives a real red mirror that only reflects red light.
  16681.  
  16682. Note that although such reflection is called specular it is not controlled by
  16683. the specular keyword. That keyword controls a specular highlight.
  16684.  
  16685. 7.6.3.5          Refraction
  16686.  
  16687. When light passes through a surface either into or out of a dense medium the
  16688. path of the ray of light is bent. Such bending is called refraction. Normally
  16689. transparent or semi-transparent surfaces in POV-Ray do not refract light.
  16690. Adding refraction 1.0 to the finish statement turns on refraction.
  16691.  
  16692. Note that it is recommended that you only use refraction 0 or refraction 1
  16693. (or even better refraction off and refraction on). Values in between will
  16694. darken the refracted light in ways that do not correspond to any physical
  16695. property. Many POV-Ray scenes were created with intermediate refraction
  16696. values before this bug was discovered so the feature has been maintained. A
  16697. more appropriate way to reduce the brightness of refracted light is to change
  16698. the filter or transmit value in the colors specified in the pigment
  16699. statement. Note also that refraction does not cause the object to be
  16700. transparent. Transparency only occurs if there is a non-zero filter or
  16701. transmit value in the color.
  16702.  
  16703. The amount of bending or refracting of light depends upon the density of the
  16704. material. Air, water, crystal and diamonds all have different densities and
  16705. thus refract differently. The index of  refraction or ior value is used by
  16706. scientists to describe the relative density of substances. The ior keyword is
  16707. used in POV-Ray to specify the value. For example:
  16708.  
  16709.   texture {
  16710.     pigment { White filter 0.9 }
  16711.     finish {
  16712.       refraction 1
  16713.       ior 1.5
  16714.     }
  16715.   }
  16716.  
  16717.  
  16718. The default ior value of 1.0 will give no refraction. The index of refraction
  16719. for air is 1.0, water is 1.33, glass is 1.5 and diamond is 2.4. The file
  16720. consts.inc pre-defines several useful values for ior.
  16721.  
  16722. Note that if a texture has a filter component and no value for refraction and
  16723. ior are supplied the renderer will simply transmit the ray through the
  16724. surface with no bending. In layered textures, the refraction and ior keywords
  16725. must be in the last texture, otherwise they will not take effect.
  16726.  
  16727. 7.6.3.5.1        Light Attenuation
  16728.  
  16729. Light attenuation is used to model the decrease in light intensity as the
  16730. light travels through a translucent object. Its syntax is:
  16731.  
  16732.   finish {
  16733.     fade_distance FADE_DISTANCE
  16734.     fade_power FADE_POWER
  16735.   }
  16736.  
  16737.  
  16738. The fade_distance keyword determines the distance the light has to travel to
  16739. reach half intensity while the fade_power keyword describes how fast the
  16740. light will fall off. For realistic effects a fade power of 1 to 2 should be
  16741. used.
  16742.  
  16743. The attenuation is calculated by a formula similar to that used for light
  16744. source attenuation.
  16745.  
  16746.                                  1
  16747.   attenuation = --------------------------------------
  16748.                  1 + (d / FADE_DISTANCE) ^ FADE_POWER
  16749.  
  16750.  
  16751. 7.6.3.5.2        Faked Caustics
  16752.  
  16753. Caustics are light effects that occur if light is reflected or refrected by
  16754. specular reflective or refractive surfaces. Imagine a glass of water standing
  16755. on a table. If sunlight falls onto the glass you will see spots of light on
  16756. the table. Some of the spots are caused by light being reflected by the glass
  16757. while some of them are caused by light being refratced by the water in the
  16758. glass.
  16759.  
  16760. Since it is a very difficult and time-consuming process to actually calculate
  16761. those effects (though it is not impossible) POV-Ray uses a quite simple
  16762. method to simulate caustics caused by refraction. This caustic effect is
  16763. limited to areas that are shaded by the translucent object. You'll get no
  16764. caustic effects from reflective surfaces nor in parts that are not shaded by
  16765. the object.
  16766.  
  16767. The syntax is:
  16768.  
  16769.   finish {
  16770.     caustics POWER
  16771.   }
  16772.  
  16773.  
  16774. 7.6.3.6          Iridescence
  16775.  
  16776. Iridescence, or Newton's thin film interference, simulates the effect of
  16777. light on surfaces with a microscopic transparent film overlay. The effect is
  16778. like an oil slick on a puddle of water or the rainbow hues of a soap bubble
  16779. (see also "Irid_Wavelength").
  16780.  
  16781. The syntax is:
  16782.  
  16783.   finish {
  16784.     irid {
  16785.       AMOUNT
  16786.       thickness FLOAT
  16787.       turbulence VECTOR
  16788.     }
  16789.   }
  16790.  
  16791.  
  16792. This finish modifies the surface color as a function of the angle between the
  16793. light source and the surface. Since the effect works in conjunction with the
  16794. position and angle of the light sources to the surface it does not behave in
  16795. the same ways as a procedural pigment pattern.
  16796.  
  16797. The AMOUNT parameter is the contribution of the iridescence effect to the
  16798. overall surface color. As a rule of thumb keep to around 0.25 (25%
  16799. contribution) or less, but experiment. If the surface is coming out too
  16800. white, try lowering the diffuse and possibly the ambient values of the
  16801. surface.
  16802.  
  16803. The thickness keyword represents the film's thickness. This is an awkward
  16804. parameter to set, since the thickness value has no relationship to the
  16805. object's scale. Changing it affects the scale or busy-ness of the effect. A
  16806. very thin film will have a high frequency of color changes while a thick film
  16807. will have large areas of color.
  16808.  
  16809. The thickness of the film can be varied with the turbulence keyword. You can
  16810. only specify the amount of turbulence with iridescence. The octaves, lambda,
  16811. and omega values are internally set and are not adjustable by the user at
  16812. this time.
  16813.  
  16814. In addition, perturbing the object's surface normal through the use of bump
  16815. patterns will affect iridescence.
  16816.  
  16817. For the curious, thin film interference occurs because, when the ray hits the
  16818. surface of the film, part of the light is reflected from that surface, while
  16819. a portion is transmitted into the film. This subsurface ray travels through
  16820. the film and eventually reflects off the opaque substrate. The light emerges
  16821. from the film slightly out of phase with the ray that was reflected from the
  16822. surface.
  16823.  
  16824. This phase shift creates interference, which varies with the wavelength of
  16825. the component colors, resulting in some wavelengths being reinforced, while
  16826. others are cancelled out. When these components are recombined, the result is
  16827. iridescence.
  16828.  
  16829. The concept used for this feature came from the book Fundamentals  of
  16830. Three-Dimensional Computer Graphics by Alan Watt (Addison-Wesley).
  16831.  
  16832. 7.6.4            Halo
  16833.  
  16834. Important notice: The halo feature in POV-Ray 3.0 are somewhat experimental.
  16835. There is a high probability that the design and implementation of these
  16836. features will be changed in future versions. We cannot guarantee that scenes
  16837. using these features in 3.0 will render identically in future releases or
  16838. that full backwards compatibility of language syntax can be maintained.
  16839.  
  16840. A halo is used to simulate some of the atmospheric effects that occur when
  16841. small particles interact with light or radiate on their own. Those effects
  16842. include clouds, fogs, fire, etc.
  16843.  
  16844. Halos are attached to an object, the so called container object, which they
  16845. completely fill. If the object is partially or completely translucent and the
  16846. object is specified to be hollow (see section "Hollow" for more details) the
  16847. halo will be visible. Thus the halo effects are limited to the space that the
  16848. object covers. This should always be kept in mind.
  16849.  
  16850. What the halo actually will look like depends on a lot of parameters. First
  16851. of all you have to specify which kind of effect you want to simulate. After
  16852. this you need to define the distribution of the particles. This is basically
  16853. done in two steps: a mapping function is selected and a density function is
  16854. chosen. The first function maps world coordinates onto a one-dimensional
  16855. interval while the later describes how this linear interval is mapped onto
  16856. the final density values.
  16857.  
  16858. The properties of the particles, such as their color and their translucency,
  16859. are given by a color map. The density values calculated by the mapping
  16860. processes are used to determine the appropriate color using this color map.
  16861.  
  16862. A ray marching process is used to volume sample the halo and to accumulate
  16863. the intensities and opacity of each interval.
  16864.  
  16865. The following sections will describe all of the halo parameters in more
  16866. detail. The complete halo syntax is given by:
  16867.  
  16868.   halo {
  16869.     attenuating | emitting | glowing | dust
  16870.     [ constant | linear | cubic | poly ]
  16871.     [ planar_mapping | spherical_mapping |
  16872.       cylindrical_mapping | box_mapping ]
  16873.     [ dust_type DUST_TYPE ]
  16874.     [ eccentricity ECCENTRICITY ]
  16875.     [ max_value MAX_VALUE ]
  16876.     [ exponent EXPONENT ]
  16877.     [ samples SAMPLES ]
  16878.     [ aa_level AA_LEVEL ]
  16879.     [ aa_threshold AA_THRESHOLD ]
  16880.     [ jitter JITTER ]
  16881.     [ turbulence <TURBULENCE> ]
  16882.     [ octaves OCTAVES ]
  16883.     [ omega OMEGA ]
  16884.     [ lambda LAMBDA ]
  16885.     [ colour_map COLOUR_MAP ]
  16886.     [ frequency FREQUENCY ]
  16887.     [ phase PHASE ]
  16888.     [ scale <VECTOR> ]
  16889.     [ rotate <VECTOR> ]
  16890.     [ translate <VECTOR> ]
  16891.   }
  16892.  
  16893.  
  16894. 7.6.4.1          Halo Mapping
  16895.  
  16896. As described above the actual particle distribution and halo appearance is
  16897. influenced by a lot of parameters. The steps that are performed during the
  16898. halo calculation will be explained below. It will also be noted where the
  16899. different halo keywords will have an effect on the calculations.
  16900.  
  16901.   1.Depending on the current sampling position along the ray, point P
  16902.     (coordinates x, y, z) inside the halo container object is calculated. The
  16903.     actual location is influenced by the jitter keyword, the number of
  16904.   2.Point P is transformed into point Q using the (current) halo'sd).
  16905.     transformation. Here all local halo transformations come into play, i.e.
  16906.   3.Turbulence is added to point Q. The amount of turbulence is given by the
  16907.     urbulence keyword. The turbulence calculation is influenced by the
  16908.   4.Radius r is calculated depending on the specified density mapping
  16909.     (planar_mapping, spherical_mapping, cylindrical_mapping, box_mapping).
  16910.   5.The density d is calculated from the radius r using the specified density
  16911.     function (constant, linear, cubic, poly) and the maximum value given by
  16912.   6.The density d is first multiplied by the frequency value, added to the
  16913.     phase value and clipped to the range from 0 to 1 before it is used to get
  16914.     the color from the color_map . If an attenuating halo is used the color
  16915.     will be determined by the total density along the ray and not by the sum
  16916.     of the colors for each sample.
  16917.  
  16918.  
  16919. All steps are repeated for each sample point along the ray that is inside the
  16920. halo container object. Steps 2 through 6 are repeated for all halos attached
  16921. to the halo container object.
  16922.  
  16923. It should be noted that in order to get a finite particle distribution, i. e.
  16924. a particle distribution that vanishes outside a finite area, a finite density
  16925. mapping and a finite density function has to be used.
  16926.  
  16927. A finite density mapping gives the constant value one for all points outside
  16928. a finite area. The box and spherical mappings are the only finite mapping
  16929. types.
  16930.  
  16931. A finite density function vanishes for all parameter values above one (there
  16932. are no negative parameter values). The only infinite density function is the
  16933. constant function.
  16934.  
  16935. Finite particle distributions are especially useful because they can always
  16936. be transformed to stay inside the halo container object. If particles leave
  16937. the container object they become invisible and the surface of the container
  16938. will be visible due to the density discontinuity at the surface.
  16939.  
  16940. 7.6.4.2          Multiple Halos
  16941.  
  16942. It is possible to put more than one halo inside a container object. This is
  16943. simply done by putting more than one halo statement inside the container
  16944. object statement like:
  16945.  
  16946.   sphere { 0, 1
  16947.     pigment { Clear }
  16948.     halo { here comes halo nr. 1 }
  16949.     halo { here comes halo nr. 2 }
  16950.     halo { here comes halo nr. 3 }
  16951.     ...
  16952.   }
  16953.  
  16954.  
  16955. The effects of the different halos are added. This is in fact similar to the
  16956. CSG union operation.
  16957.  
  16958. You should note that currently multiple attenuating halos will use the color
  16959. map of the last halo only. It is not possible to use different color maps for
  16960. multiple attenuating halos.
  16961.  
  16962. 7.6.4.3          Halo Type
  16963.  
  16964. The type of the halo is defined by one of the following mutually exclusive
  16965. keywords (if more than one is specified the last will be used). The default
  16966. is attenuating.
  16967.  
  16968.   halo {
  16969.     attenuating | emitting | glowing | dust
  16970.   }
  16971.  
  16972.  
  16973. The halo type determines how the light will interact with the particles
  16974. inside the container object. There are two basic categories of light
  16975. interaction: self-illuminated and illuminated. The first type includes the
  16976. attenuating, emitting and glowing effects while the dust effect is of the
  16977. second type.
  16978.  
  16979.  
  16980. 7.6.4.3.1        Attenuating
  16981.  
  16982. The attenuating halo that only absorbs light passing through it is rendered
  16983. by accumulating the particle density along a ray. The total halo color is
  16984. determined from the total, accumulated density and the specified color map
  16985. (see section "Halo Color Map" for details about the color map). The
  16986. background light, i. e. the light passing through the halo, is attenuated by
  16987. the total density and added to the total halo color to get the final color of
  16988. the halo.
  16989.  
  16990. This model is suited to render particle distributions with a high albedo
  16991. because the final color does not depend on the transparency of single volume
  16992. elements but only on the total transparency along the ray. The albedo of a
  16993. particle is given by the amount of light scattered by this particle in all
  16994. directions in relation to the amount of incoming light. If the particle
  16995. doesn't absorb any light the albedo is one.
  16996.  
  16997. Clouds and steams are two of the effects that can be rendered quite realistic
  16998. by adding enough turbulence.
  16999.  
  17000. 7.6.4.3.2        Dust
  17001.  
  17002. The dust halo consists of particles that do not emit any light. They only
  17003. reflect and absorb incoming light. Its syntax is:
  17004.  
  17005.   halo {
  17006.     dust
  17007.     [ dust_type DUST_TYPE ]
  17008.     [ eccentricity ECCENTRICITY ]
  17009.   }
  17010.  
  17011.  
  17012. As the ray marches through the dust all light coming from any light sources
  17013. is accumulated and scattered according to the dust type and the current dust
  17014. density. Since this light accumulation includes a test for occlusion, other
  17015. objects may cast shadows into the dust.
  17016.  
  17017. The same scattering types that are used with the atmosphere in section
  17018. "Atmosphere" can be used with the dust (the default type is isotropic
  17019. scattering). They are:
  17020.  
  17021.   #declare ISOTROPIC_SCATTERING         = 1
  17022.   #declare MIE_HAZY_SCATTERING          = 2
  17023.   #declare MIE_MURKY_SCATTERING         = 3
  17024.   #declare RAYLEIGH_SCATTERING          = 4
  17025.   #declare HENYEY_GREENSTEIN_SCATTERING = 5
  17026.  
  17027.  
  17028. The Henyey-Greenstein function needs the additional parameter eccentricity
  17029. that is described in the section about atmosphere. This keyword only applies
  17030. to dust type 5, the Henyey-Greenstein scattering.
  17031.  
  17032. 7.6.4.3.3        Emitting
  17033.  
  17034. Emitting halos only emit light. Every particle is a small light source that
  17035. emits some light. This light is not attenuated by the other particles because
  17036. they are assumed to be very small.
  17037.  
  17038. As the ray travels through the density field of an emitting halo the color of
  17039. the particles in each volume element and their differential transparency is
  17040. determined from the color map. These intensities are accumulated to get the
  17041. total color of the density field. This total intensity is added to the light
  17042. passing through the halo. The background light is attenuated by the total
  17043. density of the halo.
  17044.  
  17045. Since the emitted light is not attenuated it can be used to model effects
  17046. like fire, explosions, light beams, etc. By choosing a well suited color map
  17047. those effects can be rendered with a high degree of realism.
  17048.  
  17049. Fire is best modeled using planar mapping. Spherical mapping and high
  17050. turbulence values can be used to create explosions (it's best to use a
  17051. periodic color map and frequencies larger than one).
  17052.  
  17053. Emitting halos do not cast any light on other objects like light sources do,
  17054. even though they are made up of small, light-emitting particles. In order to
  17055. make them actually emit light hundreds or thousands of small light sources
  17056. would have to be used. This would slow down tracing by a degree that would
  17057. make it useless.
  17058.  
  17059. 7.6.4.3.4        Glowing
  17060.  
  17061. The glowing halo is similar to the emitting halo. The difference is that the
  17062. light emitted by the particles is attenuated by the other particles. This can
  17063. be seen as a combination of the attenuating and the emitting model.
  17064.  
  17065. 7.6.4.4          Density Mapping
  17066.  
  17067. The density mapping is used to map points in space onto a linear,
  17068. one-dimensional interval between 0.0 and 1.0, thus describing the appearance
  17069. of the three-dimensional particle distribution. The different mapping types
  17070. are specified by:
  17071.  
  17072.   halo {
  17073.     planar_mapping | spherical_mapping |
  17074.     cylindrical_mapping | box_mapping
  17075.   }
  17076.  
  17077.  
  17078. The default mapping type is planar mapping.
  17079.  
  17080. Since the mapping takes place in relation to the origin of the world
  17081. coordinate system the following rule must always be kept in mind: Halo
  17082. container objects ought to be unit sized objects centered at the origin. They
  17083. can be transformed later to suit the individuals needs.
  17084.  
  17085. The different mapping types are explained in more detail in the following
  17086. sections.
  17087.  
  17088. 7.6.4.4.1        Box Mapping
  17089.  
  17090. The box mapping can be used to create a box-shaped particle distribution. The
  17091. mapping is calculated by getting the maximum of the absolute values of each
  17092. coordinate as given by the formula:
  17093.  
  17094.   r(x, y, z) = max(abs(x), abs(y), abs(z))
  17095.  
  17096.  
  17097. 7.6.4.4.2        Cylindrical Mapping
  17098.  
  17099. The distance r(x,y,z) from the y-axis given by
  17100.  
  17101.   r(x, y, z) = sqrt(x*x + z*z)
  17102.  
  17103.  
  17104. is used to get the interval values. Values larger than one are clipped to
  17105. one.
  17106.  
  17107. 7.6.4.4.3        Planar Mapping
  17108.  
  17109. The distance r(x,y,z) from the x-z-plane given by
  17110.  
  17111.   r(x, y, z) = abs(y)
  17112.  
  17113.  
  17114. is used to get the interval values. Values larger than one are clipped to
  17115. one.
  17116.  
  17117. 7.6.4.4.4        Spherical Mapping
  17118.  
  17119. The distance r(x,y,z) from the origin given by
  17120.  
  17121.   r(x, y, z) = sqrt(x*x + y*y + z*z)
  17122.  
  17123.  
  17124. is used to get the interval values. Values larger than one are clipped to
  17125. one.
  17126.  
  17127. 7.6.4.5          Density Function
  17128.  
  17129. The density function determines how the actual density values are calculated
  17130. from the linear, one-dimensional interval that resulted from the density
  17131. mapping.
  17132.  
  17133. The density function is specified by the following keywords:
  17134.  
  17135.   halo {
  17136.     [ constant | linear | cubic | poly ]
  17137.     [ max_value MAX_VALUE ]
  17138.     [ exponent EXPONENT ]
  17139.   }
  17140.  
  17141.  
  17142. The exponent keyword is only used together with the poly density function.
  17143.  
  17144. The individual functions f(r) are described in the following sections. They
  17145. all map the value r(x,y,z) calculated by the density mapping onto a suitable
  17146. density range between 0 and MAX_VALUE (specified with the keyword max_value).
  17147.  
  17148. 7.6.4.5.1        Constant
  17149.  
  17150. The constant function gives the constant value MAX_VALUE regardless of the
  17151. interval value and the type of density mapping. It is calculated by the
  17152. trivial formula   f(r) = MAX_VALUE.
  17153.  
  17154.  
  17155. The constant density function.
  17156.  
  17157. The constant density function can be used to create a constant particle
  17158. distribution that is only constrained by the container object.
  17159.  
  17160. 7.6.4.5.2        Linear
  17161.  
  17162. A linear falloff from MAX_VALUE at r=0 to zero at r=1 is created with the
  17163. linear density function. It is given by:
  17164.  
  17165.   f(r) = MAX_VALUE * (1 - r)
  17166.  
  17167.  
  17168. 7.6.4.5.3        Cubic
  17169.  
  17170. The cubic function gives a smooth blend between the maximum value MAX_VALUE
  17171. at r=0 and 0 at r=1. It is given by:
  17172.  
  17173.   f(r) = MAX_VALUE * (2 * r  - 3) * r * r + 1
  17174.  
  17175.  
  17176. The cubic density function.
  17177.  
  17178.  
  17179. 7.6.4.5.4        Poly
  17180.  
  17181. A polynomial function can be used to get a large variety of density
  17182. functions. All have the maximum value MAX_VALUE at r=0 and the minimum value
  17183. 0 at r=1. It is given by:
  17184.  
  17185.   f(r) = MAX_VALUE * (1 - r) ^ EXPONENT
  17186.  
  17187.  
  17188. The polynomial density function for different exponent values.
  17189.  
  17190. The exponent is given by the exponent keyword. In case of EXPONENT=0 you'll
  17191. get a linear falloff.
  17192.  
  17193. 7.6.4.6          Halo Color Map
  17194.  
  17195. The density f(r), which ranges from 0 to MAX_VALUE, is mapped onto the color
  17196. map to get the color and differential translucency for each volume element as
  17197. the ray marches through the density field (the final color of attenuating
  17198. halos is calculated from the total density; see section "Halo Mapping" and
  17199. section "Attenuating"). The differential translucency determines for each
  17200. value of f(r) how much the total opacity has to be increased (or decreased).
  17201.  
  17202. The color map is specified by:
  17203.  
  17204.   halo {
  17205.     [ colour_map COLOUR_MAP ]
  17206.   }
  17207.  
  17208.  
  17209. The differential translucency is stored in the transmittance channel of the
  17210. map's color entries. A simple example is given by
  17211.  
  17212.   colour_map {
  17213.     [0 rgbt<1, 1, 1, 1>]
  17214.     [1 rgbt<1, 1, 1, 0>]
  17215.   }
  17216.  
  17217.  
  17218. In this example areas with a low density (small f(r)) will be translucent
  17219. (large differential translucency of 1=100%) and areas with a high density
  17220. (large f(r)) will be opaque (small differential translucency of 0=0%). You
  17221. should note that negative transmittance values can be used to create very
  17222. dense fields.
  17223.  
  17224. In the case of the dust halo the filter channels of the colors in the color
  17225. map are used to specify the amount of light that will be filtered by the
  17226. corresponding color map entry. For all other halo types the filter value is
  17227. ignored.
  17228.  
  17229.  
  17230. 7.6.4.7          Halo Sampling
  17231.  
  17232. The halo effects are calculated by marching through the density field along a
  17233. ray. At discrete steps samples are taken from the density field and evaluated
  17234. according to the color map and all other parameters. The effects of all
  17235. volume elements are accumulated to get the total effect.
  17236.  
  17237. The following parameters are used to tune the sampling process:
  17238.  
  17239.   halo {
  17240.     [ samples SAMPLES ]
  17241.     [ aa_level AA_LEVEL ]
  17242.     [ aa_threshold AA_THRESHOLD ]
  17243.     [ jitter JITTER ]
  17244.   }
  17245.  
  17246.  
  17247. 7.6.4.7.1        Number of Samples
  17248.  
  17249. The number of samples that are taken along the ray inside the halo container
  17250. object is specified by the samples keyword. The greater the number of samples
  17251. the more denser the density field is sampled and the more accurate but slower
  17252. the result will be.
  17253.  
  17254. The default number of samples is 10. This is sufficient for simple density
  17255. fields that don't use turbulence.
  17256.  
  17257. High turbulence values and dust halos normally need a large number of samples
  17258. to avoid aliasing artifacts.
  17259.  
  17260. 7.6.4.7.2        Super-Sampling
  17261.  
  17262. The sampling is prone to alias (like the atmosphere sampling in section
  17263. "Atmosphere"). One way to reduce possible aliasing artifacts is to use
  17264. super-sampling. If two neighboring samples differ too much an additional
  17265. sampling is taken in-between. This process recurses until the values of the
  17266. samples are close too each other or the maximum recursion level given by
  17267. aa_level is reached. The threshold to kick super-sampling in is given by
  17268. aa_threshold.
  17269.  
  17270. By default super-sampling is not used. The default values for aa_threshold
  17271. and aa_level are 0.3 and 3 respectively.
  17272.  
  17273. 7.6.4.7.3        Jitter
  17274.  
  17275. Jitter can be used to introduce some noise to the sampling locations. This
  17276. may help to reduce aliasing artifacts at the cost of an increased noise level
  17277. in the image. Since the human visual system is much more forgiving to noise
  17278. than it is to regular patterns this is not much of a problem.
  17279.  
  17280. By default jittering is not used. The values should be smaller than 1.0.
  17281.  
  17282.  
  17283. 7.6.4.8          Halo Modifiers
  17284.  
  17285. This section covers all general halo modifiers. They are:
  17286.  
  17287.   halo {
  17288.     [ turbulence <TURBULENCE> ]
  17289.     [ octaves OCTAVES ]
  17290.     [ omega OMEGA ]
  17291.     [ lambda LAMBDA ]
  17292.     [ frequency FREQUENCY ]
  17293.     [ phase PHASE ]
  17294.     [ scale <VECTOR> ]
  17295.     [ rotate <VECTOR> ]
  17296.     [ translate <VECTOR> ]
  17297.   }
  17298.  
  17299.  
  17300. 7.6.4.8.1        Frequency Modifier
  17301.  
  17302. The frequency parameter adjusts the number of times the density interval is
  17303. mapped onto itself, i. e. the range from 0.0 to 1.0, before it is mapped onto
  17304. the color map. The formula doing this is:
  17305.  
  17306.   f_new(r) = (f(r) * FREQUENCY + PHASE) modulo 1.0
  17307.  
  17308.  
  17309. 7.6.4.8.2        Phase Modifier
  17310.  
  17311. The phase parameter determines the offset at which the mapping of the density
  17312. field onto itself starts. See the formula in the previous section for how the
  17313. pahse is used.
  17314.  
  17315.  
  17316. 7.6.4.8.3        Transformation Modifiers
  17317.  
  17318. Halos can be transformed using the rotate, scale and translate keywords. You
  17319. have to be careful that you don't move the density field out of the container
  17320. object though.
  17321.  
  17322. 7.6.5            Special Textures
  17323.  
  17324. Special textures are complex textures made up of multiple textures. The
  17325. component textures may be plain textures or may be made up of special
  17326. textures. A plain texture has just one pigment, normal and finish statement
  17327. (and maby some halo statements). Even a pigment with a pigment map is still
  17328. one pigment and thus considered a plain texture as are normals with normal
  17329. map statements.
  17330.  
  17331. Special textures use either a texture_map keyword to specify a blend or
  17332. pattern of textures or they use a bitmap similar to an image map called a
  17333. material map (specified with the material_map keyword).
  17334.  
  17335. There are restrictions on using special textures. A special texture may not
  17336. be used as a default texture (see section "Default Directive"). A special
  17337. texture cannot be used as a layer in a layered texture however you may use
  17338. layered textures as any of the textures contained within a special texture.
  17339.  
  17340. 7.6.5.1          Texture Maps
  17341.  
  17342. In addition to specifying blended color with a color map or a pigment map you
  17343. may create a blend of textures using texture_map. The syntax for a texture
  17344. map is identical to the pigment map except you specify a texture in each map
  17345. entry.
  17346.  
  17347. A texture map is specified by...
  17348.  
  17349.   texture{
  17350.     PATTERN_TYPE
  17351.     texture_map {
  17352.       [ NUM_1 TEXTURE_BODY_1]
  17353.       [ NUM_2 TEXTURE_BODY_2]
  17354.       [ NUM_3 TEXTURE_BODY_3]
  17355.        ...
  17356.     }
  17357.     TEXTURE_MODIFIERS...
  17358.   }
  17359.  
  17360.  
  17361. Where NUM_1, NUM_2, ... are float values between 0.0 and 1.0 inclusive. A
  17362. TEXTURE_BODY is anything that would normally appear inside a texture
  17363. statement but the texture keyword and {} braces are not needed. Note that the
  17364. [] brackets are part of the actual statement. They are not notational symbols
  17365. denoting optional parts. The brackets surround each entry in the map. There
  17366. may be from 2 to 256 entries in the map.
  17367.  
  17368. For example:
  17369.  
  17370.   texture {
  17371.     gradient x       //this is the PATTERN_TYPE
  17372.     texture_map {
  17373.       [0.3  pigment{Red} finish{phong 1}]
  17374.       [0.3  T_Wood11]    //this is a texture identifier
  17375.       [0.6  T_Wood11]
  17376.       [0.9  pigment{DMFWood4} finish{Shiny}]
  17377.     }
  17378.   }
  17379.  
  17380.  
  17381. When the gradient x function returns values from 0.0 to 0.3 the red
  17382. highlighted texture is used. From 0.3 to 0.6 the texture identifier T_Wood11
  17383. is used. From 0.6 up to 0.9 a blend of T_Wood11 and a shiny DMFWood4 is used.
  17384. From 0.9 on up only the shiny wood is used.
  17385.  
  17386. Texture maps may be nested to any level of complexity you desire. The
  17387. textures in a map may have color maps or texture maps or any type of texture
  17388. you want.
  17389.  
  17390. The blended area of a texture map works by fully calculating both
  17391. contributing textures in their entirety and then linearly interpolating the
  17392. apparent colors. This means that reflection, refraction and lighting
  17393. calculations are done twice for every point. This is in contrast to using a
  17394. pigment map and a normal map in a plain texture, where the pigment is
  17395. computed, then the normal, then reflection, refraction and lighting are
  17396. calculated once for that point.
  17397.  
  17398. Entire textures may also be used with the block patterns such as checker,
  17399. hexagon and brick. For example...
  17400.  
  17401.   texture {
  17402.     checker
  17403.       texture { T_Wood12 scale .8 }
  17404.       texture {
  17405.         pigment { White_Marble }
  17406.         finish { Shiny }
  17407.         scale .5
  17408.       }
  17409.     }
  17410.   }
  17411.  
  17412.  
  17413. Note that in the case of block patterns the texture wrapping is required
  17414. around the texture information. Also note that this syntax prohibits the use
  17415. of a layered texture however you can work around this by declaring a texture
  17416. identifier for the layered texture and referencing the identifier.
  17417.  
  17418. A texture map is also used with the average pattern type. See "Average" for
  17419. details.
  17420.  
  17421. 7.6.5.2          Tiles
  17422.  
  17423. Earlier versions of POV-Ray had a special texture called tiles texture that
  17424. created a checkered pattern of textures. Although it is still supported for
  17425. backwards computability you should use a checker block texture pattern
  17426. described in section "Texture Maps" rather than tiles textures.
  17427.  
  17428. 7.6.5.3          Material Maps
  17429.  
  17430. The material map special texture extends the concept of image maps to apply
  17431. to entire textures rather than solid colors. A material map allows you to
  17432. wrap a 2-D bit-mapped texture pattern around your 3-D objects.
  17433.  
  17434. Instead of placing a solid color of the image on the shape like an image map,
  17435. an entire texture is specified based on the index or color of the image at
  17436. that point. You must specify a list of textures to be used like a texture
  17437. palette rather than the usual color palette.
  17438.  
  17439. When used with mapped file types such as GIF, and some PNG and TGA images,
  17440. the index of the pixel is used as an index into the list of textures you
  17441. supply. For unmapped file types such as some PNG and TGA images the 8 bit
  17442. value of the red component in the range 0-255 is used as an index.
  17443.  
  17444. If the index of a pixel is greater than the number of textures in your list
  17445. then the index is taken modulo N where N is the length of your list of
  17446. textures.
  17447.  
  17448. 7.6.5.3.1        Specifying a Material Map
  17449.  
  17450. The syntax of a material map is...
  17451.  
  17452.   texture {
  17453.     material_map {
  17454.       FILE_TYPE "filename"
  17455.       BITMAP_MODIFIERS...
  17456.       texture {...} // First used for index 0
  17457.       texture {...} // Second texture used for index 1
  17458.       texture {...} // Third texture used for index 2
  17459.       texture {...} // Fourth texture used for index 3
  17460.                     // and so on for however many used.
  17461.     }
  17462.     TRANSFORMATION...
  17463.   }
  17464.  
  17465.  
  17466. Where FILE_TYPE is one of the following keywords gif, tga, iff, ppm, pgm, png
  17467. or sys. This is followed by the name of the file using any valid string
  17468. expression. Several optional modifiers may follow the file specification. The
  17469. modifiers are described below. Note that earlier versions of POV-Ray allowed
  17470. some modifiers before the FILE_TYPE but that syntax is being phased out in
  17471. favor of the syntax described here.
  17472.  
  17473. Filenames specified in the material_map statements will be searched for in
  17474. the home (current) directory first and, if not found, will then be searched
  17475. for in directories specified by any +L switches or Library_Path options. This
  17476. would facilitate keeping all your material map files in a separate
  17477. subdirectory and specifying a library path to them. Note that any operating
  17478. system default paths are not searched unless you also specify them as a
  17479. Library_Path.
  17480.  
  17481. By default, the material is mapped onto the x-y-plane. The material is
  17482. projected onto the object as though there were a slide projector somewhere in
  17483. the -z-direction. The material exactly fills the square area from (x,y)
  17484. coordinates (0,0) to (1,1) regardless of the bitmap's original size in
  17485. pixels. If you would like to change this default you may translate, rotate or
  17486. scale the texture to map it onto the object's surface as desired.
  17487.  
  17488. The file name is optionally followed by one or more BITMAP_MODIFIERS. See
  17489. section "Bitmap Modifiers" for other details.
  17490.  
  17491. After a material_map statement but still inside the texture statement you may
  17492. apply any legal texture modifiers. Note that no other pigment, normal, finish
  17493. or halo statements may be added to the texture outside the material map. The
  17494. following is illegal:
  17495.  
  17496.   texture {
  17497.     material_map {
  17498.       gif "matmap.gif"
  17499.       texture {T1}
  17500.       texture {T2}
  17501.       texture {T3}
  17502.     }
  17503.     finish {phong 1.0}
  17504.   }
  17505.  
  17506.  
  17507. The finish must be individually added to each texture.
  17508.  
  17509. Note that earlier versions of POV-Ray allowed such specifications but they
  17510. were ignored. The above restrictions on syntax were necessary for various bug
  17511. fixes. This means some POV-Ray 1.0 scenes using material maps many need minor
  17512. modifications that cannot be done automatically with the version
  17513. compatibility mode.
  17514.  
  17515. If particular index values are not used in an image then it may be necessary
  17516. to supply dummy textures. It may be necessary to use a paint program or other
  17517. utility to examine the map file's palette to determine how to arrange the
  17518. texture list.
  17519.  
  17520. The textures within a material map texture may be layered but material map
  17521. textures do not work as part of a layered texture. To use a layered texture
  17522. inside a material map you must declare it as a texture identifier and invoke
  17523. it in the texture list.
  17524.  
  17525. 7.6.6            Layered Textures
  17526.  
  17527. It is possible to create a variety of special effects using layered textures.
  17528. A layered texture consists of several textures that are partially transparent
  17529. and are laid one on top of the other to create a more complex texture. The
  17530. different texture layers show through the transparent portions to create the
  17531. appearance of one texture that is a combination of several textures.
  17532.  
  17533. You create layered textures by listing two or more textures one right after
  17534. the other. The last texture listed will be the top layer, the first one
  17535. listed will be the bottom layer. All textures in a layered texture other than
  17536. the bottom layer should have some transparency. For example:
  17537.  
  17538.   object {
  17539.     My_Object
  17540.     texture {T1}  // the bottom layer
  17541.     texture {T2}  // a semi-transparent layer
  17542.     texture {T3}  // the top semi-transparent layer
  17543.   }
  17544.  
  17545.  
  17546. In this example T2 shows only where T3 is transparent and T1 shows only where
  17547. T2 and T3 are transparent.
  17548.  
  17549. The color of underlying layers is filtered by upper layers but the results do
  17550. not look exactly like a series of transparent surfaces. If you had a stack of
  17551. surfaces with the textures applied to each, the light would be filtered
  17552. twice: once on the way in as the lower layers are illuminated by filtered
  17553. light and once on the way out. Layered textures do not filter the
  17554. illumination on the way in. Other parts of the lighting calculations work
  17555. differently as well. The results look great and allow for fantastic looking
  17556. textures but they are simply different from multiple surfaces. See stones.inc
  17557. in the standard include files directory for some magnificent layered
  17558. textures.
  17559.  
  17560. Note layered textures must use the texture wrapped around any pigment, normal
  17561. or finish statements. Do not use multiple pigment, normal or finish
  17562. statements without putting them inside the texture statement.
  17563.  
  17564. Layered textures may be declared. For example
  17565.  
  17566.   #declare Layered_Examp =
  17567.     texture {T1}
  17568.     texture {T2}
  17569.     texture {T3}
  17570.  
  17571.  
  17572. may be invoked as follows:
  17573.  
  17574.   object {
  17575.     My_Object
  17576.     texture {
  17577.       Layer_Examp
  17578.       // Any pigment, normal or finish here
  17579.       // modifies the bottom layer only.
  17580.     }
  17581.   }
  17582.  
  17583.  
  17584. If you wish to use a layered texture in a block pattern, such as checker,
  17585. hexagon, or brick, or in a material map, you must declare it first and then
  17586. reference it inside a single texture statement. A special texture cannot be
  17587. used as a layer in a layered texture however you may use layered textures as
  17588. any of the textures contained within a special texture.
  17589.  
  17590. 7.6.7            Patterns
  17591.  
  17592. POV-Ray uses a method called three-dimensional solid texturing to define the
  17593. color, bumpiness and other properties of a surface. You specify the way that
  17594. the texture varies over a surface by specifying a pattern. Patterns are used
  17595. in pigments, normals and texture maps.
  17596.  
  17597. All patterns in POV-Ray are three dimensional. For every point in space, each
  17598. pattern has a unique value. Patterns do not wrap around a surface like
  17599. putting wallpaper on an object. The patterns exist in 3d and the objects are
  17600. carved from them like carving an object from a solid block of wood or stone.
  17601.  
  17602. Consider a block of wood. It contains light and dark bands that are
  17603. concentric cylinders being the growth rings of the wood. On the end of the
  17604. block you see these concentric circles. Along its length you see lines that
  17605. are the veins. However the pattern exists throughout the entire block. If you
  17606. cut or carve the wood it reveals the pattern inside. Similarly an onion
  17607. consists of concentric spheres that are visible only when you slice it.
  17608. Marble stone consists of wavy layers of colored sediments that harden into
  17609. rock.
  17610.  
  17611. These solid patterns can be simulated using mathematical functions. Other
  17612. random patterns such as granite or bumps and dents can be generated using a
  17613. random number system and a noise function.
  17614.  
  17615. In each case, the x, y, z coordinate of a point on a surface is used to
  17616. compute some mathematical function that returns a float value. When used with
  17617. color maps or pigment maps, that value looks up the color of the pigment to
  17618. be used. In normal statements the pattern function result modifies or
  17619. perturbs the surface normal vector to give a bumpy appearance. Used with a
  17620. texture map, the function result determines which combinations of entire
  17621. textures to be used.
  17622.  
  17623. The following sections describe each pattern. See the sections "Pigment" and
  17624. "Normal" for more details on how to use patterns.
  17625.  
  17626. 7.6.7.1          Agate
  17627.  
  17628. The agate pattern is a banded pattern similar to marble but it uses a
  17629. specialized built-in turbulence function that is different from the
  17630. traditional turbulence. The traditional turbulence can be used as well but it
  17631. is generally not necessary because agate is already very turbulent. You may
  17632. control the amount of the built-in turbulence by adding the agate_turb
  17633. keyword followed by a float value. For example:   pigment {
  17634.     agate
  17635.     agate_turb 0.5
  17636.     color_map {
  17637.       ...
  17638.     }
  17639.   }
  17640.  
  17641.  
  17642. The agate pattern uses the ramp_wave wave type by default but may use any
  17643. wave type. The pattern may be used with color_map, pigment_map, normal_map,
  17644. slope_map and texture_map.
  17645.  
  17646. 7.6.7.2          Average
  17647.  
  17648. Technically average is not a pattern type but it is listed here because the
  17649. syntax is similar to other patterns. Typically a pattern type specifies how
  17650. colors or normals are chosen from a pigment map or normal map, however
  17651. average tells POV-Ray to average together all of the patterns you specify.
  17652. Average was originally designed to be used in a normal statement with a
  17653. normal map as a method of specifying more than one normal pattern on the same
  17654. surface. However average may be used in a pigment statement with a pigment
  17655. map or in a texture statement with a texture map to average colors too.
  17656.  
  17657. When used with pigments, the syntax is:
  17658.  
  17659.   pigment {
  17660.     average
  17661.     pigment_map
  17662.     {
  17663.       [WEIGHT_1 PIGMENT_BODY_1]
  17664.       [WEIGHT_2 PIGMENT_BODY_2]
  17665.       ...
  17666.       [WEIGHT_n PIGMENT_BODY_n]
  17667.     }
  17668.     PIGMENT_MODIFIER
  17669.   }
  17670.  
  17671.  
  17672. Similarly you may use a texture map in a texture statement. All textures are
  17673. fully computed. The resulting colors are then weighted and averaged.
  17674.  
  17675. When used with a normal map in a normal statement, multiple copies of the
  17676. original surface normal are created and are perturbed by each pattern. The
  17677. perturbed normals are then weighted, added and normalized.
  17678.  
  17679. See the sections "Pigment Maps", "Normal Maps" and "Texture Maps" for more
  17680. information.
  17681.  
  17682. 7.6.7.3          Bozo
  17683.  
  17684. The bozo pattern is a very smooth, random noise function that is
  17685. traditionally used with some turbulence to create clouds. The spotted pattern
  17686. is identical to bozo but in early versions of POV-Ray spotted did not allow
  17687. turbulence to be added. Turbulence can now be added to any pattern so these
  17688. are redundant but both are retained for backwards compatibility. The bumps
  17689. pattern is also identical to bozo when used anywhere except in a normal
  17690. statement. When used as a normal, bumps uses a slightly different method to
  17691. perturb the normal with a similar noise function.
  17692.  
  17693. The bozo noise function has the following properties:
  17694.  
  17695.   1.It's defined over 3D space i.e., it takes x, y, and z and returns the
  17696.   2.If two points are far apart, the noise values at those points are
  17697.   3.If two points are close together, the noise values at those points are
  17698.     close to each other.
  17699.  
  17700.  
  17701. You can visualize this as having a large room and a thermometer that ranges
  17702. from 0.0 to 1.0. Each point in the room has a temperature. Points that are
  17703. far apart have relatively random temperatures. Points that are close together
  17704. have close temperatures. The temperature changes smoothly but randomly as we
  17705. move through the room.
  17706.  
  17707. Now let's place an object into this room along with an artist. The artist
  17708. measures the temperature at each point on the object and paints that point a
  17709. different color depending on the temperature. What do we get? A POV-Ray bozo
  17710. texture!
  17711.  
  17712. The bozo pattern uses the ramp_wave wave type by default but may use any wave
  17713. type. The pattern may be used with color_map, pigment_map, normal_map,
  17714. slope_map and texture_map.
  17715.  
  17716. 7.6.7.4          Brick
  17717.  
  17718. The brick pattern generates a pattern of bricks. The bricks are offset by
  17719. half a brick length on every other row in the x- and z-directions. A layer of
  17720. mortar surrounds each brick. The syntax is given by
  17721.  
  17722.   pigment {
  17723.     brick COLOR_1, COLOR_2
  17724.     brick_size VECTOR
  17725.     mortar FLOAT
  17726.   }
  17727.  
  17728.  
  17729. where COLOR_1 is the color of the mortar and COLOR_2 is the color of the
  17730. brick itself. If no colors are specified a default deep red and dark gray are
  17731. used. The default size of the brick and mortar together is <8, 3, 4.5> units.
  17732. The default thickness of the mortar is 0.5 units. These values may be changed
  17733. using the optional brick_size and mortar pattern modifiers. You may also use
  17734. pigment statements in place of the colors. For example:
  17735.  
  17736.   pigment {
  17737.     brick pigment{Jade}, pigment{Black_Marble}
  17738.   }
  17739.  
  17740.  
  17741. When used with normals, the syntax is   normal {
  17742.     brick BUMP_FLOAT
  17743.   }
  17744.  
  17745.  
  17746. Where BUMP_FLOAT is an optional bump size float value. You may also use full
  17747. normal statements. For example:
  17748.  
  17749.   normal {
  17750.     brick normal{bumps 0.2}, normal{granite 0.3}
  17751.   }
  17752.  
  17753.  
  17754. When used with textures, the syntax is
  17755.  
  17756.   texture {
  17757.     brick texture{T_Gold_1A}, texture{Stone12}
  17758.   }
  17759.  
  17760.  
  17761. This is a block pattern which cannot use wave types, color map, or slope map
  17762. modifiers.
  17763.  
  17764. 7.6.7.5          Bumps
  17765.  
  17766. The bumps pattern was originally designed only to be used as a normal
  17767. pattern. It uses a very smooth, random noise function that creates the look
  17768. of rolling hills when scaled large or a bumpy orange peal when scaled small.
  17769. Usually the bumps are about 1 unit apart.
  17770.  
  17771. When used as a normal, bumps uses a specialized normal perturbation function.
  17772. This means that the bumps pattern cannot be used with normal map, slope map
  17773. or wave type modifiers in a normal statement.
  17774.  
  17775. When used as a pigment pattern or texture pattern, the bumps pattern is
  17776. identical to bozo or spotted and is similar to normal bumps but is not
  17777. identical as are most normals when compared to pigments. When used as pigment
  17778. or texture statements the bumps pattern uses the ramp_wave wave type by
  17779. default but may use any wave type. The pattern may be used with color_map,
  17780. pigment_map, and texture_map.
  17781.  
  17782. 7.6.7.6          Checker
  17783.  
  17784. The checker pattern produces a checkered pattern consisting of alternating
  17785. squares of COLOR_1 and COLOR_2. If no colors are specified then default blue
  17786. and green colors are used.
  17787.  
  17788.   pigment { checker COLOR_1, COLOR_2 }
  17789.  
  17790.  
  17791. The checker pattern is actually a series of cubes that are one unit in size.
  17792. Imagine a bunch of 1 inch cubes made from two different colors of modeling
  17793. clay. Now imagine arranging the cubes in an alternating check pattern and
  17794. stacking them in layer after layer so that the colors still alternate in
  17795. every direction. Eventually you would have a larger cube. The pattern of
  17796. checks on each side is what the POV-Ray checker pattern produces when applied
  17797. to a box object. Finally imagine cutting away at the cube until it is carved
  17798. into a smooth sphere or any other shape. This is what the checker pattern
  17799. would look like on an object of any kind.
  17800.  
  17801. You may also use pigment statements in place of the colors. For example:
  17802.  
  17803.   pigment { checker pigment{Jade}, pigment{Black_Marble} }
  17804.  
  17805.  
  17806. When used with normals, the syntax is
  17807.  
  17808.   normal { checker BUMP_FLOAT }
  17809.  
  17810.  
  17811. Where BUMP_FLOAT is an optional bump size float value. You may also use full
  17812. normal statements. For example:
  17813.  
  17814.   normal {
  17815.     checker normal{gradient x scale .2},
  17816.             normal{gradient y scale .2}
  17817.   }
  17818.  
  17819.  
  17820. When used with textures, the syntax is...
  17821.  
  17822.   texture { checker texture{T_Wood_3A},texture{Stone12} }
  17823.  
  17824.  
  17825. This use of checker as a texture pattern replaces the special tiles texture
  17826. in previous versions of POV-Ray. You may still use tiles but it may be phased
  17827. out in future versions so checker textures are best.
  17828.  
  17829. This is a block pattern which cannot use wave types, color map, or slope map
  17830. modifiers.
  17831.  
  17832. 7.6.7.7          Crackle
  17833.  
  17834. The crackle pattern is a set of random tiled polygons. With a large scale and
  17835. no turbulence it makes a pretty good stone wall or floor. With a small scale
  17836. and no turbulence it makes a pretty good crackle ceramic glaze. Using high
  17837. turbulence it makes a good marble that avoids the problem of apparent
  17838. parallel layers in traditional marble.
  17839.  
  17840. Mathematically, the set crackle(p)=0 is a 3D Voronoi diagram of a field of
  17841. semi random points and crackle(p) < 0 is the distance from the set along the
  17842. shortest path (a Voronoi diagram is the locus of points equidistant from
  17843. their two nearest neighbors from a set of disjoint points, like the membranes
  17844. in suds are to the centers of the bubbles).
  17845.  
  17846. The crackle pattern uses the ramp_wave wave type by default but may use any
  17847. wave type. The pattern may be used with color_map, pigment_map, normal_map,
  17848. slope_map and texture_map.
  17849.  
  17850. 7.6.7.8          Dents
  17851.  
  17852. The dents pattern was originally designed only to be used as a normal
  17853. pattern. It is especially interesting when used with metallic textures. It
  17854. gives impressions into the metal surface that look like dents have been
  17855. beaten into the surface with a hammer. Usually the dents are about 1 unit
  17856. apart.
  17857.  
  17858. When used as a normal pattern, dents uses a specialized normal perturbation
  17859. function. This means that the dents pattern cannot be used with normal map,
  17860. slope map or wave type modifiers in a normal statement.
  17861.  
  17862. When used as a pigment pattern or texture pattern, the dents pattern is
  17863. similar to normal dents but is not identical as are most normals when
  17864. compared to pigments. When used in pigment or texture statements the dents
  17865. pattern uses the ramp_wave wave type by default but may use any wave type.
  17866. The pattern may be used with color_map, pigment_map and texture_map.
  17867.  
  17868. 7.6.7.9          Gradient
  17869.  
  17870. One of the simplest patterns is the gradient pattern. It is specified as
  17871.  
  17872.   pigment {gradient VECTOR}
  17873.  
  17874.  
  17875. where VECTOR is a vector pointing in the direction that the colors blend. For
  17876. example    pigment { gradient x } // bands of color vary as you move
  17877.                           // along the "x" direction.
  17878.  
  17879.  
  17880. produces a series of smooth bands of color that look like layers of colors
  17881. next to each other. Points at x=0 are the first color in the color map. As
  17882. the x location increases it smoothly turns to the last color at x=1. Then it
  17883. starts over with the first again and gradually turns into the last color at
  17884. x=2. The pattern reverses for negative values of x. Using gradient y or
  17885. gradient z makes the colors blend along the y- or z-axis. Any vector may be
  17886. used but x, y and z are most common.
  17887.  
  17888. As a normal pattern, gradient generates a saw-tooth or ramped wave
  17889. appearance. The syntax is
  17890.  
  17891.    normal { gradient VECTOR, BUMP_FLOAT}
  17892.  
  17893.  
  17894. where the VECTOR giving the orientation is a required parameter but the
  17895. BUMP_FLOAT bump size which follows is optional.
  17896.  
  17897. The pattern uses the ramp_wave wave type by default but may use any wave
  17898. type. The pattern may be used with color_map, pigment_map, normal_map,
  17899. slope_map and texture_map.
  17900.  
  17901. 7.6.7.10         Granite
  17902.  
  17903. This pattern uses a simple 1/f fractal noise function to give a good granite
  17904. pattern. This pattern is used with creative color maps in stones.inc to
  17905. create some gorgeous layered stone textures.
  17906.  
  17907. As a normal pattern it creates an extremely bumpy surface that looks like a
  17908. gravel driveway or rough stone.
  17909.  
  17910. The pattern uses the ramp_wave wave type by default but may use any wave
  17911. type. The pattern may be used with color_map, pigment_map, normal_map,
  17912. slope_map and texture_map.
  17913.  
  17914. 7.6.7.11         Hexagon
  17915.  
  17916. The hexagon pattern is a block pattern that generates a repeating pattern of
  17917. hexagons in the x-y-plane. In this instance imagine tall rods that are
  17918. hexagonal in shape and are parallel to the y-axis and grouped in bundles like
  17919. shown in the example image. Three separate colors should be specified as
  17920. follows:
  17921.  
  17922.   pigment { hexagon COLOR_1, COLOR_2, COLOR_3 }
  17923.  
  17924.  
  17925.      _____
  17926.     /     \
  17927.    /   C2  _____
  17928.   |       /     \
  17929.   | _____/   C3  \
  17930.   | /            /|
  17931.    /   C1  _____/ |
  17932.   |       /|    | |
  17933.   | _____/ |    | |
  17934.   | |     | |    | |
  17935.   | |     | |    | |
  17936.   | |     | |    | |
  17937.   | |     | |    | |
  17938.   | |     | |    |
  17939.   | |     | |    |
  17940.     |     |
  17941.     |     |
  17942. The hexagon pattern.
  17943.  
  17944. The three colors will repeat the hexagonal pattern with hexagon COLOR_1
  17945. centered at the origin, COLOR_2 in the +z-direction and COLOR_3 to either
  17946. side. Each side of the hexagon is one unit long. The hexagonal rods of color
  17947. extend infinitely in the +y- and -y-directions. If no colors are specified
  17948. then default blue, green and red colors are used.
  17949.  
  17950. You may also use pigment statements in place of the colors. For example:
  17951.  
  17952.   pigment {
  17953.     hexagon pigment { Jade },
  17954.             pigment { White_Marble },
  17955.             pigment { Black_Marble }
  17956.   }
  17957.  
  17958.  
  17959. When used with normals, the syntax is
  17960.  
  17961.   normal { hexagon BUMP_FLOAT }
  17962.  
  17963.  
  17964. Where BUMP_FLOAT is an optional bump size float value. You may also use full
  17965. normal statements. For example:
  17966.  
  17967.   normal {
  17968.     hexagon
  17969.       normal { gradient x scale .2 },
  17970.       normal { gradient y scale .2 },
  17971.       normal { bumps scale .2 }
  17972.   }
  17973.  
  17974.  
  17975. When used with textures, the syntax is...
  17976.  
  17977.   texture {
  17978.     hexagon
  17979.       texture { T_Gold_3A },
  17980.       texture { T_Wood_3A },
  17981.       texture { Stone12 }
  17982.   }
  17983.  
  17984.  
  17985. This is a block pattern which cannot use wave types, color map, or slope map
  17986. modifiers.
  17987.  
  17988. 7.6.7.12         Leopard
  17989.  
  17990. Leopard creates regular geometric pattern of circular spots.
  17991.  
  17992. The pattern uses the ramp_wave wave type by default but may use any wave
  17993. type. The pattern may be used with color_map, pigment_map, normal_map,
  17994. slope_map and texture_map.
  17995.  
  17996. 7.6.7.13         Mandel
  17997.  
  17998. The mandel pattern computes the standard Mandelbrot fractal pattern and
  17999. projects it onto the x-y-plane. It uses the x and y coordinates to compute
  18000. the Mandelbrot set. The pattern is specified with the keyword mandel followed
  18001. by an integer number. This number is the maximum number of iterations to be
  18002. used to compute the set. Typical values range from 10 up to 256 but any
  18003. positive integer may be used. For example:
  18004.  
  18005.   pigment {
  18006.     mandel 25
  18007.     color_map {
  18008.       [0.0  color Cyan]
  18009.       [0.3  color Yellow]
  18010.       [0.6  color Magenta]
  18011.       [1.0  color Cyan]
  18012.     }
  18013.     scale .5
  18014.   }
  18015.  
  18016.  
  18017. The value passed to the color map is computed by the formula:
  18018.  
  18019.   value = number_of_iterations / max_iterations
  18020.  
  18021.  
  18022. When used as a normal pattern, the syntax is...
  18023.  
  18024.   normal {
  18025.     mandel ITER, BUMP_AMOUNT
  18026.   }
  18027.  
  18028.  
  18029. where the required integer ITER value is optionally followed by a float bump
  18030. size.
  18031.  
  18032. The pattern extends infinitely in the z-direction similar to a planar image
  18033. map. The pattern uses the ramp_wave wave type by default but may use any wave
  18034. type. The pattern may be used with color_map, pigment_map, normal_map,
  18035. slope_map and texture_map.
  18036.  
  18037. 7.6.7.14         Marble
  18038.  
  18039. The marble pattern is very similar to the gradient x pattern. The gradient
  18040. pattern uses a default ramp_wave wave type which means it uses colors from
  18041. the color map from 0.0 up to 1.0 at location x=1 but then jumps back to the
  18042. first color for x > 1 and repeats the pattern again and again. However the
  18043. marble pattern uses the triangle_wave wave type in which it uses the color
  18044. map from 0 to 1 but then it reverses the map and blends from 1 back to zero.
  18045. For example:
  18046.  
  18047.   pigment {
  18048.     gradient x
  18049.     color_map {
  18050.       [0.0  color Yellow]
  18051.       [1.0  color Cyan]
  18052.     }
  18053.   }
  18054.  
  18055.  
  18056. This blends from yellow to cyan and then it abruptly changes back to yellow
  18057. and repeats. However replacing gradient x with marble smoothly blends from
  18058. yellow to cyan as the x coordinate goes from 0.0 to 0.5 and then smoothly
  18059. blends back from cyan to yellow by x=1.0.
  18060.  
  18061. Earlier versions of POV-Ray did not allow you to change wave types. Now that
  18062. wave types can be changed for most any pattern, the distinction between
  18063. marble and gradient x is only a matter of default wave types.
  18064.  
  18065. When used with turbulence and an appropriate color map, this pattern looks
  18066. like veins of color of real marble, jade or other types of stone. By default,
  18067. marble has no turbulence.
  18068.  
  18069. The pattern may be used with color_map, pigment_map, normal_map, slope_map
  18070. and texture_map.
  18071.  
  18072. 7.6.7.15         Onion
  18073.  
  18074. Onion is a pattern of concentric spheres like the layers of an onion. Each
  18075. layer is one unit thick.
  18076.  
  18077. The pattern uses the ramp_wave wave type by default but may use any wave
  18078. type. The pattern may be used with color_map, pigment_map, normal_map,
  18079. slope_map and texture_map.
  18080.  
  18081. 7.6.7.16         Quilted
  18082.  
  18083. The quilted pattern was originally designed only to be used as a normal
  18084. pattern. The quilted pattern is so named because it can create a pattern
  18085. somewhat like a quilt or a tiled surface. The squares are actually 3-D cubes
  18086. that are 1 unit in size.
  18087.  
  18088. When used as a normal pattern it uses a specialized normal perturbation
  18089. function. This means that the quilted pattern cannot be used with normal map,
  18090. slope map or wave type modifiers in a normal statement.
  18091.  
  18092. When used as a pigment pattern or texture pattern, the quilted pattern is
  18093. similar to normal quilted but is not identical as are most normals when
  18094. compared to pigments. When used in pigment or texture statements the quilted
  18095. pattern uses the ramp_wave wave type by default but may use any wave type.
  18096. The pattern may be used with color_map, pigment_map and texture_map.
  18097.  
  18098. The two parameters control0 and control1 are used to adjust the curvature of
  18099. the seam or gouge area between the quilts. The syntax is:
  18100.  
  18101.   normal {
  18102.     quilted AMOUNT
  18103.     control0 C0
  18104.     control1 C1
  18105.   }
  18106.  
  18107.  
  18108. The values should generally be kept to around the 0.0 to 1.0 range. The
  18109. default value is 1.0 if none is specified. Think of this gouge between the
  18110. tiles in cross-section as a sloped line.
  18111.  
  18112. Quilted pattern with c0=0 and different values for c1.
  18113.  
  18114. Quilted pattern with c0=0.33 and different values for c1.
  18115.  
  18116. Quilted pattern with c0=0.67 and different values for c1.
  18117.  
  18118. Quilted pattern with c0=1 and different values for c1.
  18119.  
  18120. This straight slope can be made to curve by adjusting the two control values.
  18121. The control values adjust the slope at the top and bottom of the curve. A
  18122. control values of 0 at both ends will give a linear slope, as shown above,
  18123. yielding a hard edge. A control value of 1 at both ends will give an "s"
  18124. shaped curve, resulting in a softer, more rounded edge.
  18125.  
  18126. 7.6.7.17         Radial
  18127.  
  18128. The radial pattern is a radial blend that wraps around the +y-axis. The color
  18129. for value 0.0 starts at the +x-direction and wraps the color map around from
  18130. east to west with 0.25 in the -z-direction, 0.5 in -x, 0.75 at +z and back to
  18131. 1.0 at +x. Typically the pattern is used with a frequency modifier to create
  18132. multiple bands that radiate from the y-axis.
  18133.  
  18134. The pattern uses the ramp_wave wave type by default but may use any wave
  18135. type. The pattern may be used with color_map, pigment_map, normal_map,
  18136. slope_map and texture_map.
  18137.  
  18138. 7.6.7.18         Ripples
  18139.  
  18140. The ripples pattern was originally designed only to be used as a normal
  18141. pattern. It makes the surface look like ripples of water. The ripples radiate
  18142. from 10 random locations inside the unit cube area <0,0,0> to <1,1,1>. Scale
  18143. the pattern to make the centers closer or farther apart.
  18144.  
  18145. Usually the ripples from any given center are about 1 unit apart. The
  18146. frequency keyword changes the spacing between ripples. The phase keyword can
  18147. be used to move the ripples outwards for realistic animation.
  18148.  
  18149. The number of ripple centers can be changed with the global parameter
  18150. global_settings { number_of_waves FLOAT } somewhere in the scene. This
  18151. affects the entire scene. You cannot change the number of wave centers on
  18152. individual patterns. See section "Number_Of_Waves" for details.
  18153.  
  18154. When used as a normal pattern, ripples uses a specialized normal perturbation
  18155. function. This means that the ripples pattern cannot be used with normal map,
  18156. slope map or wave type modifiers in a normal statement.
  18157.  
  18158. When used in pigment or texture statements the ripples pattern uses the
  18159. ramp_wave wave type by default but may use any wave type. The pattern may be
  18160. used with color_map, pigment_map and texture_map.
  18161.  
  18162. 7.6.7.19         Spiral1
  18163.  
  18164. The spiral1 pattern creates a spiral that winds around the y-axis similar to
  18165. a screw. Its syntax is:
  18166.  
  18167.   pigment {
  18168.     spiral1 NUMBER_OF_ARMS
  18169.   }
  18170.  
  18171.  
  18172. The NUMBER_OF_ARMS value determines how may arms are winding around the
  18173. y-axis.
  18174.  
  18175. The pattern uses the triangle_wave wave type by default but may use any wave
  18176. type. The pattern may be used with color_map, pigment_map, normal_map,
  18177. slope_map and texture_map.
  18178.  
  18179. 7.6.7.20         Spiral2
  18180.  
  18181. The spiral2 pattern is a modification of the spiral1 pattern with an
  18182. extraordinary look.
  18183.  
  18184. The pattern uses the triangle_wave wave type by default but may use any wave
  18185. type. The pattern may be used with color_map, pigment_map, normal_map,
  18186. slope_map and texture_map.
  18187.  
  18188. 7.6.7.21         Spotted
  18189.  
  18190. The spotted pattern is identical to the bozo pattern. Early versions of
  18191. POV-Ray did not allow turbulence to be used with spotted. Now that any
  18192. pattern can use turbulence there is no difference between bozo and spotted.
  18193. See section "Bozo" for details.
  18194.  
  18195. 7.6.7.22         Waves
  18196.  
  18197. The waves pattern was originally designed only to be used as a normal
  18198. pattern. The waves pattern looks similar to the ripples pattern except the
  18199. features are rounder and broader. The effect is to make waves that look more
  18200. like deep ocean waves. The waves radiate from ten random locations inside the
  18201. unit cube area <0,0,0> to <1,1,1>. Scale the pattern to make the centers
  18202. closer or farther apart.
  18203.  
  18204. Usually the waves from any given center are about 1 unit apart. The frequency
  18205. keyword changes the spacing between waves. The phase keyword can be used to
  18206. move the waves outwards for realistic animation.
  18207.  
  18208. The number of ripple centers can be changed with the global parameter
  18209. global_settings { number_of_waves FLOAT } somewhere in the scene. This
  18210. affects the entire scene. You cannot change the number of wave centers on
  18211. individual patterns. See section "Number_Of_Waves" for details.
  18212.  
  18213. When used as a normal pattern, waves uses a specialized normal perturbation
  18214. function. This means that the waves pattern cannot be used with normal map,
  18215. slope map or wave type modifiers in a normal statement.
  18216.  
  18217. When used in pigment or texture statements the waves pattern uses the
  18218. ramp_wave wave type by default but may use any wave type. The pattern may be
  18219. used with color_map, pigment_map and texture_map.
  18220.  
  18221. 7.6.7.23         Wood
  18222.  
  18223. The wood pattern consists of concentric cylinders centered on the z-axis.
  18224. When appropriately colored, the bands look like the growth rings and veins in
  18225. real wood. Small amounts of turbulence should be added to make it look more
  18226. realistic. By default, wood has no turbulence.
  18227.  
  18228. Unlike most patterns, the wood pattern uses the triangle_wave wave type by
  18229. default. This means that like marble, wood uses color map values 0.0 to 1.0
  18230. then repeats the colors in reverse order from 1.0 to 0.0. However you may use
  18231. any wave type. The pattern may be used with color_map, pigment_map,
  18232. normal_map, slope_map and texture_map.
  18233.  
  18234. 7.6.7.24         Wrinkles
  18235.  
  18236. The wrinkles pattern was originally designed only to be used as a normal
  18237. pattern. It uses a 1/f noise pattern similar to granite but the features in
  18238. wrinkles are sharper. The pattern can be used to simulate wrinkled cellophane
  18239. or foil. It also makes an excellent stucco texture.
  18240.  
  18241. When used as a normal pattern it uses a specialized normal perturbation
  18242. function. This means that the wrinkles pattern cannot be used with normal
  18243. map, slope map or wave type modifiers in a normal statement.
  18244.  
  18245. When used as a pigment pattern or texture pattern, the wrinkles pattern is
  18246. similar to normal wrinkles but is not identical as are most normals when
  18247. compared to pigments. When used in pigment or texture statements the wrinkles
  18248. pattern uses the ramp_wave wave type by default but may use any wave type.
  18249. The pattern may be used with color_map, pigment_map and texture_map.
  18250.  
  18251. 7.6.8            Pattern Modifiers
  18252.  
  18253. Pattern modifiers are statements or parameters which modify how a pattern is
  18254. evaluated or tells what to do with the pattern. The modifiers color_map and
  18255. pigment_map apply only to pigments. See section "Pigment". The modifiers
  18256. bump_size, slope_map and normal_map apply only to normals. See section
  18257. "Normal". The texture_map modifier can only be used with textures. See
  18258. section "Texture Maps".
  18259.  
  18260. The pattern modifiers in the following section can be used with pigment,
  18261. normal or texture patterns.
  18262.  
  18263. 7.6.8.1          Transforming Patterns
  18264.  
  18265. The most common pattern modifiers are the transformation modifiers translate,
  18266. rotate, scale and matrix. For details on these commands see section
  18267. "Transformations".
  18268.  
  18269. These modifiers may be placed inside pigment, normal and texture statements
  18270. to change the position, size and orientation of the patterns.
  18271.  
  18272. In general the order of transformations relative to other pattern modifiers
  18273. such as turbulence, color_map and other maps is not important. For example
  18274. scaling before or after turbulence makes no difference. The turbulence is
  18275. done first, then the scaling regardless of which is specified first. However
  18276. the order in which transformations are performed relative to warp statements
  18277. is important. See "Warps" for details.
  18278.  
  18279. 7.6.8.2          Frequency and Phase
  18280.  
  18281. The frequency and phase modifiers act as a type of scale and translate
  18282. modifiers for color_map, pigment_map, normal_map, slope_map and texture_map.
  18283. This discussion uses a color map as an example but the same principles apply
  18284. to pigment maps, normal maps, slope maps and texture maps.
  18285.  
  18286. The frequency keyword adjusts the number of times that a color map repeats
  18287. over one cycle of a pattern. For example gradient covers color map values 0
  18288. to 1 over the range from x=0 to x=1. By adding frequency 2.0 the color map
  18289. repeats twice over that same range. The same effect can be achieved using
  18290. scale 0.5*x so the frequency keyword isn't that useful for patterns like
  18291. gradient.
  18292.  
  18293. However the radial pattern wraps the color map around the +y-axis once. If
  18294. you wanted two copies of the map (or 3 or 10 or 100) you'd have to build a
  18295. bigger map. Adding frequency 2.0 causes the color map to be used twice per
  18296. revolution. Try this:
  18297.  
  18298.   pigment {
  18299.     radial
  18300.     color_map{[0.5 color Red][0.5 color White]}
  18301.     frequency 6
  18302.   }
  18303.  
  18304.  
  18305. The result is six sets of red and white radial stripes evenly spaced around
  18306. the object.
  18307.  
  18308. The float after frequency can be any value. Values greater than 1.0 causes
  18309. more than one copy of the map to be used. Values from 0.0 to 1.0 cause a
  18310. fraction of the map to be used. Negative values reverses the map.
  18311.  
  18312. The phase value causes the map entries to be shifted so that the map starts
  18313. and ends at a different place. In the example above if you render successive
  18314. frames at phase 0 then phase 0.1, phase 0.2 etc you could create an animation
  18315. that rotates the stripes. The same effect can be easily achieved by rotating
  18316. the radial pigment using rotate  y*Angle but there are other uses where phase
  18317. can be handy.
  18318.  
  18319. Sometimes you create a great looking gradient or wood color map but you want
  18320. the grain slightly adjusted in or out. You could re-order the color map
  18321. entries but that's a pain. A phase adjustment will shift everything but keep
  18322. the same scale. Try animating a mandel pigment for a color palette rotation
  18323. effect.
  18324.  
  18325. Frequency and phase have no effect on block patterns checker, brick and
  18326. hexagon nor do they effect image maps, bump maps or material maps. They also
  18327. have no effect in normal statements when used with bumps, dents, quilted or
  18328. wrinkles because these normal patterns cannot use normal_map or slope_map.
  18329.  
  18330. They can be used with normal patterns ripples and waves even though these two
  18331. patterns cannot use normal_map or slope_map either. When used with ripples or
  18332. waves, frequency adjusts the space between features and phase can be adjusted
  18333. from 0.0 to 1.0 to cause the ripple or waves to move relative to their center
  18334. for animating the features.
  18335.  
  18336. These values work by applying the following formula
  18337.  
  18338.   NEW_VALUE = fmod ( OLD_VALUE * FREQUENCY + PHASE, 1.0 ).
  18339.  
  18340.  
  18341. 7.6.8.3          Waveform
  18342.  
  18343. Most patterns that take color_map, pigment_map, slope_map, normal_map or
  18344. texture_map use the entries in the map in order from 0.0 to 1.0. The wood and
  18345. marble patterns use the map from 0.0 to 1.0 and then reverses it and runs it
  18346. from 1.0 to 0.0. The difference can easily be seen when these patterns are
  18347. used as normal patterns with no maps.
  18348.  
  18349. Patterns such as gradient or onion generate a grove or slot that looks like a
  18350. ramp that drops off sharply. This is called a ramp_wave wave type. However
  18351. wood and marble slope upwards to a peak, then slope down again in a
  18352. triangle_wave. In previous versions of POV-Ray there was no way to change the
  18353. wave types. You could simulate a triangle wave on a ramp wave pattern by
  18354. duplicating the map entries in reverse, however there was no way to use a
  18355. ramp wave on wood or marble.
  18356.  
  18357. Now any pattern that takes a map can have the default wave type overridden.
  18358. For example:
  18359.  
  18360.   pigment { wood color_map { MyMap } ramp_wave }
  18361.  
  18362.  
  18363. Also available are sine_wave and scallop_wave types. These types are of most
  18364. use in normal patterns as a type of built-in slope map. The sine_wave takes
  18365. the zig-zag of a ramp wave and turns it into a gentle rolling wave with
  18366. smooth transitions. The scallop_wave uses the absolute value of the sine wave
  18367. which looks like corduroy when scaled small or like a stack of cylinders when
  18368. scaled larger.
  18369.  
  18370. Although any of these wave types can be used for pigments, normals or
  18371. textures, the sine_wave and scallop_wave types are not as noticeable on
  18372. pigments or textures as they are for normals.
  18373.  
  18374. Wave types have no effect on block patterns checker, brick and hexagon nor do
  18375. they effect image maps, bump maps or material maps. They also have no effect
  18376. in normal statements when used with bumps, dents, quilted or wrinkles because
  18377. these normal patterns cannot use normal_map or slope_map.
  18378.  
  18379. 7.6.8.4          Turbulence
  18380.  
  18381. The keyword turbulence followed by a float or vector may be used to stir up
  18382. any pigment, normal, texture, irid or halo. A number of optional parameters
  18383. may be used with turbulence to control how it is computed. For example:
  18384.  
  18385.   pigment  {
  18386.     wood color_map { MyMap }
  18387.     turbulence TURB_VECTOR
  18388.     octaves FLOAT
  18389.     omega FLOAT
  18390.     lambda FLOAT
  18391.   }
  18392.  
  18393.  
  18394. Typical turbulence values range from the default 0.0, which is no turbulence,
  18395. to 1.0 or more, which is very turbulent. If a vector is specified different
  18396. amounts of turbulence are applied in the x-, y- and z-direction. For example
  18397.  
  18398.   turbulence <1.0, 0.6, 0.1>
  18399.  
  18400.  
  18401. has much turbulence in the x-direction, a moderate amount in the y-direction
  18402. and a small amount in the z-direction.
  18403.  
  18404. Turbulence uses a random noise function called DNoise. This is similar to the
  18405. noise used in the bozo pattern except that instead of giving a single value
  18406. it gives a direction. You can think of it as the direction that the wind is
  18407. blowing at that spot. Points close together generate almost the same value
  18408. but points far apart are randomly different.
  18409.  
  18410. In general the order of turbulence parameters relative to other pattern
  18411. modifiers such as transformations, color maps and other maps is not
  18412. important. For example scaling before or after turbulence makes no
  18413. difference. The turbulence is done first, then the scaling regardless of
  18414. which is specified first. See section "Warps" for a way to work around this
  18415. behavior.
  18416.  
  18417. Turbulence uses DNoise to push a point around in several steps called
  18418. octaves. We locate the point we want to evaluate, then push it around a bit
  18419. using turbulence to get to a different point then look up the color or
  18420. pattern of the new point.
  18421.  
  18422. It says in effect Don't give me the color at this spot... take a  few random
  18423. steps in different directions and give me that color. Each step is typically
  18424. half as long as the one before. For example:
  18425.  
  18426.   P ------------------------->
  18427.            First Move        /
  18428.                             /
  18429.                            /
  18430.                           /Second
  18431.                          /  Move
  18432.                         /
  18433.                  ______/
  18434.                  \
  18435.                   \
  18436.                    Q - Final point.
  18437. Turbulence random walk.
  18438.  
  18439. The magnitude of these steps is controlled by the turbulence value. There are
  18440. three additional parameters which control how turbulence is computed. They
  18441. are octaves, lambda and omega. Each is optional. Each is followed by a single
  18442. float value. Each has no effect when there is no turbulence.
  18443.  
  18444. 7.6.8.5          Octaves
  18445.  
  18446. The octaves value controls the number of steps of turbulence that are
  18447. computed. Legal values range from 1 to 10. The default value of 6 is a fairly
  18448. high value; you won't see much change by setting it to a higher value because
  18449. the extra steps are too small. Float values are truncated to integer. Smaller
  18450. numbers of octaves give a gentler, wavy turbulence and computes faster.
  18451. Higher octaves create more jagged or fuzzy turbulence and takes longer to
  18452. compute.
  18453.  
  18454. 7.6.8.6          Lambda
  18455.  
  18456. The lambda parameter controls how statistically different the random move of
  18457. an octave is compared to its previous octave. The default value is 2.0 which
  18458. is quite random. Values close to lambda 1.0 will straighten out the
  18459. randomness of the path in the diagram above. The zig-zag steps in the
  18460. calculation are in nearly the same direction. Higher values can look more
  18461. swirly under some circumstances.
  18462.  
  18463. 7.6.8.7          Omega
  18464.  
  18465. The omega value controls how large each successive octave step is compared to
  18466. the previous value. Each successive octave of turbulence is multiplied by the
  18467. omega value. The default omega 0.5 means that each octave is 1/2 the size of
  18468. the previous one. Higher omega values mean that 2nd, 3rd, 4th and up octaves
  18469. contribute more turbulence giving a sharper, crinkly look while smaller
  18470. omegas give a fuzzy kind of turbulence that gets blurry in places.
  18471.  
  18472. 7.6.8.8          Warps
  18473.  
  18474. The warp statement is a pattern modifier that is similar to turbulence.
  18475. Turbulence works by taking the pattern evaluation point and pushing it about
  18476. in a series of random steps. However warps push the point in very
  18477. well-defined, non-random, geometric ways. The warp statement also overcomes
  18478. some limitations of traditional turbulence and transformations by giving the
  18479. user more control over the order in which turbulence, transformation and warp
  18480. modifiers are applied to the pattern.
  18481.  
  18482. Currently there are three types of warps but the syntax was designed to allow
  18483. future expansion. The first two, the repeat warp and the black_hole warp are
  18484. new features for POV-Ray that modify the pattern in geometric ways. The other
  18485. warp provides an alternative way to specify turbulence.
  18486.  
  18487. The syntax for using a warp statement in a pigment is
  18488.  
  18489.   pigment {
  18490.     PATTERN_TYPE
  18491.     PIGMENT_MODIFIERS...
  18492.     warp { WARP_ITEMS...}
  18493.     OTHER_PIGMENT_MODIFIERS...
  18494.   }
  18495.  
  18496.  
  18497. Similarly warps may be used in normals and textures. You may have as many
  18498. separate warp statements as you like in each pattern. The placement of warp
  18499. statements relative to other modifiers such as color_map or turbulence is not
  18500. important. However placement of warp statements relative to each other and to
  18501. transformations is significant. Multiple warps and transformations are
  18502. evaluated in the order in which you specify them. For example if you
  18503. translate, then warp or warp, then translate, the results can be different.
  18504.  
  18505. 7.6.8.8.1        Black Hole Warp
  18506.  
  18507. A black hole is so named because of its similarity to real black holes. Just
  18508. like the real thing, you cannot actually see a black hole. The only way to
  18509. detect its presence is by the effect it has on things that surround it.
  18510. Unlike the real thing, however, it won't swallow you up and compress your
  18511. entire body to a volume of, say, 2.0 10-10 microns in diameter if you get too
  18512. close (We're working on that part).
  18513.  
  18514. Take, for example, a woodgrain. Using POV-Ray's normal turbulence and other
  18515. texture modifier functions, you can get a nice, random appearance to the
  18516. grain. But in its randomness it is regular - it is regularly random! Adding a
  18517. black hole allows you to create a localised disturbance in a woodgrain in
  18518. either one or multiple locations. The black hole can have the effect of
  18519. either sucking the surrounding texture into itself (like the real thing) or
  18520. pushing it away. In the latter case, applied to a woodgrain, it would look to
  18521. the viewer as if there were a knothole in the wood. In this text we use a
  18522. woodgrain regularly as an example, because it is ideally suitable to
  18523. explaining black holes. However, black holes may in fact be used with any
  18524. texture.
  18525.  
  18526. The effect that the black hole has on the texture can be specified. By
  18527. default, it sucks with the strength calculated exponentially
  18528. (inverse-square). You can change this if you like.
  18529.  
  18530. Black holes may be used anywhere a Warp is permitted. The syntax is:
  18531.  
  18532.   warp
  18533.   {
  18534.     black_hole <CENTER>, RADIUS
  18535.     [falloff VALUE]
  18536.     [strength VALUE]
  18537.     [repeat <VECTOR>]
  18538.     [turbulence <VECTOR>]
  18539.     [inverse]
  18540.   }
  18541.  
  18542.  
  18543. Some examples are given by
  18544.  
  18545.   warp
  18546.   {
  18547.     black_hole <0, 0, 0>, 0.5
  18548.   }
  18549.  
  18550.   warp
  18551.   {
  18552.     black_hole <0.15, 0.125, 0>, 0.5
  18553.     falloff 7
  18554.     strength 1.0
  18555.     repeat <1.25, 1.25, 0>
  18556.     turbulence <0.25, 0.25, 0>
  18557.     inverse
  18558.   }
  18559.  
  18560.   warp
  18561.   {
  18562.     black_hole <0, 0, 0>, 1.0
  18563.     falloff 2
  18564.     strength 2
  18565.     inverse
  18566.   }
  18567.  
  18568.  
  18569. In order to fully understand how a black hole works, it is important to know
  18570. the theory behind it. A black hole (or any warp) works by taking a point and
  18571. perturbing it to another location. The amount of perturbation depends on the
  18572. strength of the black hole at the original point passed in to it. The amount
  18573. of perturbation directly relates to the amount of visual movement that you
  18574. can see occur in a texture. The stronger the black hole at the input
  18575. co-ordinate the more that original co-ordinate is moved to another location
  18576. (either closer to or further away from the center of the black hole.)
  18577.  
  18578. Movement always occurs on the vector that exists between the input point and
  18579. the center of the black hole.
  18580.  
  18581. Black holes are considered to be spheres. For a point to be affected by a
  18582. black hole, it must be within the sphere's volume.
  18583.  
  18584. Suppose you have a black hole at <1,1,1> and a point at <1,2,1>. If this
  18585. point is perturbed by a total amount of +1 units its new location is <1,3,1>,
  18586. which is on a direct line extrapolated from the vector between <1,1,1> and
  18587. <1,2,1>. In this case the point is pushed away from the black hole, which is
  18588. not normal behaviour but is good for demonstration purposes.
  18589.  
  18590. The internal properties of a black hole are as follows.
  18591.  
  18592.   Falloff          The power of two by which the effect falls off (default
  18593.   Turbulence       If set, each new repeated black hole's position isem in.
  18594.   Turbulence_VectorThe maximum <x,y,z> factor for turbulence randomness.
  18595.  
  18596.  
  18597. Each of these are discussed below.
  18598.  
  18599. Center: A vector defining the center of the sphere that represents the black
  18600. hole. If the black hole has Repeat set it is the offset within each block.
  18601.  
  18602. Radius: A number giving the length, in units, of the radius of the sphere
  18603. that represents the black hole.
  18604.  
  18605. If a point is not within radius units of <center> it cannot be affected by
  18606. the black hole and will not be perturbed.
  18607.  
  18608. Falloff: The power by which the effect of the black hole falls off. The
  18609. default is two. The force of the black hole at any given point, before
  18610. applying the Strength modifier, is as follows.
  18611.  
  18612. First, convert the distance from the point to the center to a proportion (0
  18613. to 1) that the point is from the edge of the black hole. A point on the
  18614. perimeter of the black hole will be 0.0; a point at the centre will be 1.0; a
  18615. point exactly halfway will be 0.5, and so forth.
  18616.  
  18617. Mentally you can consider this to be a closeness factor. A closeness of 1.0
  18618. is as close as you can get to the center (i. e. at the center), a closeness
  18619. of 0.0 is as far away as you can get from the center and still be inside the
  18620. black hole and a closeness of 0.5 means the point is exactly halfway between
  18621. the two.
  18622.  
  18623. Call this value c. Raise c to the power specified in Falloff. By default
  18624. Falloff is 2, so this is c^2 or c squared. The resulting value is the force
  18625. of the black hole at that exact location and is used, after applying the
  18626. Strength scaling factor as described below, to determine how much the point
  18627. is perturbed in space.
  18628.  
  18629. For example, if c is 0.5 the force is 0.5^2 or 0.25. If c is 0.25 the force
  18630. is 0.125. But if c is exactly 1.0 the force is 1.0.
  18631.  
  18632. Recall
  18633. that as c gets smaller the point is farther from the center of the black
  18634. hole. Using the default power of 2, you can see that as c reduces, the force
  18635. reduces exponentially in an inverse-square relationship. Put in plain
  18636. english, it means that the force is much stronger (by a power of two) towards
  18637. the center than it is at the outside.
  18638.  
  18639. By increasing Falloff, you can increase the magnitude of the falloff. A large
  18640. value will mean points towards the perimeter will hardly be affected at all
  18641. and points towards the center will be affected strongly.
  18642.  
  18643. A value of 1.0 for Falloff will mean that the effect is linear. A point that
  18644. is exactly halfway to the center of the black hole will be affected by a
  18645. force of exactly 0.5.
  18646.  
  18647. A value of Falloff of less than one but greater than zero means that as you
  18648. get closer to the outside, the force increases rather than decreases. This
  18649. can have some uses but there is a side effect. Recall that the effect of a
  18650. black hole ceases outside its perimeter. This means that points just within
  18651. the permiter will be affected strongly and those just outside not at all.
  18652. This would lead to a visible border, shaped as a sphere.
  18653.  
  18654. A value for Falloff of 0 would mean that the force would be 1.0 for all
  18655. points within the black hole, since any number larger 0 raised to the power
  18656. of 0 is 1.0.
  18657.  
  18658. The magnitude of the movement of the point is determined basically by the
  18659. value of force after scaling. We'll consider scaling later. Lets take an
  18660. example.
  18661.  
  18662. Suppose we have a black hole of radius 2.0 and a point that is exactly 1.0
  18663. units from the center. That means it is exactly half-way to the center and
  18664. that c would be 0.5. If we use the default falloff of 2 the force at that
  18665. point is 0.5^2 or 0.25. What this means is that we must move the point by
  18666. 0.25 of its distance from the center. In this case it is 1.0 units from the
  18667. center, so we move it by 1.0*0.25 or 0.25 units. This gives a final distance
  18668. of 1.0-(1.0*0.25) or 0.75 units from the center, on a direct line in 3D space
  18669. between the original position and the center.
  18670.  
  18671. If the point were part of, say, a wood grain, the wood grain would appear to
  18672. bend towards the (invisible) center of the black hole. If the Inverse flag
  18673. were set, however, it would be pushed away, meaning its final position would
  18674. be 1.0+(1.0*0.25) or 1.25 units from the center.
  18675.  
  18676. Strength: The Strength gives you a bit more control over how much a point is
  18677. perturbed by the black hole. Basically, the force of the black hole (as
  18678. determined above) is multiplied by the value of Strength, which defaults to
  18679. 1.0. If you set Strength to 0.5, for example, all points within the black
  18680. hole will be moved by only half as much as they would have been. If you set
  18681. it to 2.0 they will be moved twice as much.
  18682.  
  18683. There is a rider to the latter example, though - the movement is clipped to a
  18684. maximum of the original distance from the center. That is to say, a point
  18685. that is 0.75 units from the center may only be moved by a maximum of 0.75
  18686. units either towards the center or away from it, regardless of the value of
  18687. Strength. The result of this clipping is that you will have an exclusion area
  18688. near the centre of the black hole where all points whose final force value
  18689. exceeded or equaled 1.0 were moved by a fixed amount.
  18690.  
  18691. Inverted: If Inverted is set points are pushed away from the center instead
  18692. of being pulled in.
  18693.  
  18694. Repeat: Repeat allows you to simulate the effect of many black holes without
  18695. having to explicitly declare them. Repeat is a vector that tells POV-Ray to
  18696. use this black hole at multiple locations.
  18697.  
  18698. If you're not interested in the theory behind all this, just skip the
  18699. following text and use the values given in the summary below.
  18700.  
  18701. Using Repeat logically divides your scene up into cubes, the first being
  18702. located at <0,0,0> and going to < repeat>. Suppose your repeat vector was
  18703. <1,5,2>. The first cube would be from <0,0,0> to < 1,5,2>. This cube repeats,
  18704. so there would be one at < -1,-5,-2>, <1,5,2>, <2,10,4> and so forth in all
  18705. directions, ad infinitum.
  18706.  
  18707. When you use Repeat, the center of the black hole does not specify an
  18708. absolute location in your scene but an offset into each block. It is only
  18709. possible to use positive offsets. Negative values will produce undefined
  18710. results.
  18711.  
  18712. Suppose your center was <0.5,1,0.25> and the repeat vector is <2,2,2>. This
  18713. gives us a block at < 0,0,0> and <2,2,2>, etc. The centers of the black
  18714. hole's for these blocks would be <0,0,0> + < 0.5,1.0,0.25>, i. e.
  18715. <0.5,1.0,0.25>, and < 2,2,2> + <0.5,1.0,0.25>, i. e. < 2,5,3.0,2.25>.
  18716.  
  18717. Due to the way repeats are calculated internally, there is a restriction on
  18718. the values you specify for the repeat vector. Basically, each black hole must
  18719. be totally enclosed within each block (or cube), with no part crossing into a
  18720. neighbouring one. This means that, for each of the x, y and z dimensions, the
  18721. offset of the center may not be less than the radius, and the repeat value
  18722. for that dimension must be >=the center plus the radius since any other
  18723. values would allow the black hole to cross a boundary. Put another way, for
  18724. each of x, y and z
  18725.  
  18726. radius <= offset or center <= repeat - radius.
  18727.  
  18728.  
  18729. If the repeat vector in any dimension is too small to fit this criteria, it
  18730. will be increased and a warning message issued. If the center is less than
  18731. the radius it will also be moved but no message will be issued.
  18732.  
  18733. Note that none of the above should be read to mean that you can't overlap
  18734. black holes. You most certainly can and in fact this can produce some most
  18735. useful effects. The restriction only applies to elements of the same black
  18736. hole which is repeating. You can declare a second black hole that also
  18737. repeats and its elements can quite happily overlap the first and causing the
  18738. appropriate interactions.
  18739.  
  18740. It is legal for the repeat value for any dimension to be 0, meaning that
  18741. POV-Ray will not repeat the black hole in that direction.
  18742.  
  18743. Turbulence: Turbulence can only be used with Repeat. It allows an element of
  18744. randomness to be inserted into the way the black holes repeat, to cause a
  18745. more natural look. A good example would be an array of knotholes in wood - it
  18746. would look rather artificial if each knothole were an exact distance from the
  18747. previous.
  18748.  
  18749. The turbulence vector is a measurement that is added to each individual back
  18750. hole in an array, after each axis of the vector is multiplied by a different
  18751. random amount ranging from 0 to 1.
  18752.  
  18753. For example, suppose you have a repeating element of a black hole that is
  18754. supposed to be at <2,2,2>. You have specified a turbulence vector of <4,5,3>,
  18755. meaning you want the position to be able to vary by no more than 1.0 units in
  18756. the X direction, 3.0 units in the Y direction and 2.0 in Z. This means that
  18757. the valid ranges of the new position are as follows
  18758.  
  18759. X can be from 2 to 6.
  18760.  
  18761. Y can be from 2 to 7.
  18762. Z can be from 2 to 5.
  18763.  
  18764.  
  18765. The resulting actual position of the black hole's center for that particular
  18766. repeat element is random (but consistent, so renders will be repeatable) and
  18767. somewhere within the above co-ordinates.
  18768.  
  18769. There is a rider on the use of turbulence, which basically is the same as
  18770. that of the repeat vector. You can't specify a value which would cause a
  18771. black hole to potentially cross outside of its particular block.
  18772.  
  18773. Since POV-Ray doesn't know in advance how much a position will be changed due
  18774. to the random nature of the changes, it enforces a rule that is similar to
  18775. the one for Repeat, except it adds the maximum possible variation for each
  18776. axis to the center. For example, suppose you had a black hole with a center
  18777. of <1.0, 1.0, 1.0>, radius of 0.5 and a turbulence of <0.5, 0.25, 0> -
  18778. normally, the minimum repeat would be <1.5, 1.5, 1.5>. However, now we take
  18779. into account the turbulence, meaning the minimum repeat vector is actually
  18780. <2.0, 1.75, 1.5>.
  18781.  
  18782. Repeat summarized: For each of x, y and z the offset of the center must be
  18783. >=radius and the value of the repeat must be \ge center + radius +
  18784. turbulence. The exception being that repeat may be 0 for any dimension, which
  18785. means do not repeat in that direction.
  18786.  
  18787. 7.6.8.8.2        Repeat Warp
  18788.  
  18789. The repeat warp causes a section of the pattern to be repeated over and over.
  18790. It takes a slice out of the pattern and makes multiple copies of it
  18791. side-by-side. The warp has many uses but was originally designed to make it
  18792. easy to model wood veneer textures. Veneer is made by taking very thin slices
  18793. from a log and placing them side-by-side on some other backing material. You
  18794. see side-by-side nearly identical ring patterns but each will be a slice
  18795. perhaps 1/32th of an inch deeper.
  18796.  
  18797. The syntax for a repeat warp is
  18798.  
  18799.   warp { repeat VECTOR  offset VECTOR  flip VECTOR }
  18800.  
  18801.  
  18802. The repeat vector specifies the direction in which the pattern repeats and
  18803. the width of the repeated area. This vector must lie entirely along an axis.
  18804. In other words, two of its three components must be 0. For example
  18805.  
  18806.   pigment {
  18807.     wood
  18808.     warp {repeat 2*x}
  18809.   }
  18810.  
  18811.  
  18812. which means that from x=0 to x=2 you get whatever the pattern usually is. But
  18813. from x=2 to x=4 you get the same thing exactly shifted two units over in the
  18814. x-direction. To evaluate it you simply take the x-coordinate modulo 2.
  18815. Unfortunately you get exact duplicates which isn't very realistic. The
  18816. optional offset vector tells how much to translate the pattern each time it
  18817. repeats. For example
  18818.  
  18819.   pigment {
  18820.     wood
  18821.     warp {repeat x*2  offset z*0.05}
  18822.   }
  18823.  
  18824.  
  18825. means that we slice the first copy from x=0 to x=2 at z=0 but at x=2 to x=4
  18826. we offset to z=0.05. In the 4 to 6 interval we slice at z=0.10. At the n-th
  18827. copy we slice at 0.05 n z. Thus each copy is slightly different. There are no
  18828. restrictions on the offset vector.
  18829.  
  18830. Finally the flip vector causes the pattern to be flipped or mirrored every
  18831. other copy of the pattern. The first copy of the pattern in the positive
  18832. direction from the axis is not flipped. The next farther is, the next is not,
  18833. etc. The flip vector is a three component x, y, z vector but each component
  18834. is treated as a boolean value that tells if you should or should not flip
  18835. along a given axis. For example
  18836.  
  18837.   pigment {
  18838.     wood
  18839.     warp {repeat 2*x  flip <1,1,0>}
  18840.   }
  18841.  
  18842.  
  18843. means that every other copy of the pattern will be mirrored about the x- and
  18844. y- axis but not the z-axis. A non-zero value means flip and zero means do not
  18845. flip about that axis. The magnitude of the values in the flip vector doesn't
  18846. matter.
  18847.  
  18848. 7.6.8.8.3        Turbulence Warp
  18849.  
  18850. The POV-Ray language contains an ambiguity and limitation on the way you
  18851. specify turbulence and transformations such as translate, rotate, scale and
  18852. matrix transforms. Usually the turbulence is done first. Then all translate,
  18853. rotate, scale and matrix operations are always done after turbulence
  18854. regardless of the order in which you specify them. For example this
  18855.  
  18856.  pigment {
  18857.    wood
  18858.    scale .5
  18859.    turbulence .2
  18860.  }
  18861.  
  18862.  
  18863. works exactly the same as
  18864.  
  18865.  pigment {
  18866.    wood
  18867.    turbulence .2
  18868.    scale .5
  18869.  }
  18870.  
  18871.  
  18872. The turbulence is always first. A better example of this limitation is with
  18873. uneven turbulence and rotations.
  18874.  
  18875.   pigment {
  18876.     wood
  18877.     turbulence 0.5*y
  18878.     rotate z*60
  18879.   }
  18880.  
  18881.   // as compared to
  18882.  
  18883.   pigment {
  18884.    wood
  18885.    rotate z*60
  18886.    turbulence 0.5*y
  18887.   }
  18888.  
  18889.  
  18890. The results will be the same either way even though you'd think it should
  18891. look different.
  18892.  
  18893. We cannot change this basic behavior in POV-Ray now because lots of scenes
  18894. would potentially render differently if suddenly the order transformation vs
  18895. turbulence suddenly mattered when in the past, it didn't.
  18896.  
  18897. However, by specifying our turbulence inside warp statement you tell POV-Ray
  18898. that the order in which turbulence, transformations and other warps are
  18899. applied is significant. Here's an example of a turbulence warp.
  18900.  
  18901.   warp { turbulence <0,1,1> octaves 3 lambda 1.5 omega 0.3 }
  18902.  
  18903.  
  18904. The significance is that this
  18905.  
  18906.  pigment {
  18907.    wood
  18908.    translate <1,2,3> rotate x*45 scale 2
  18909.    warp { turbulence <0,1,1> octaves 3 lambda 1.5 omega 0.3 }
  18910.  }
  18911.  
  18912.  
  18913. produces different results than this...
  18914.  
  18915.  pigment {
  18916.    wood
  18917.    warp { turbulence <0,1,1> octaves 3 lambda 1.5 omega 0.3 }
  18918.    translate <1,2,3> rotate x*45 scale 2
  18919.  }
  18920.  
  18921.  
  18922. You may specify turbulence without using a warp statement. However you cannot
  18923. control the order in which they are evaluated unless you put them in a warp.
  18924.  
  18925. The evaluation rules are as follows:
  18926.  
  18927.   1)First any turbulence not inside a warp statement is applied regardless of
  18928.   2)Next each warp statement, translate, rotate, scale or matrix one-by-one,
  18929.     is applied in the order the user specifies. If you want turbulence done
  18930.     in a specific order, you simply specify it inside a warp in the proper
  18931. place.
  18932.  
  18933. 7.6.8.9          Bitmap Modifiers
  18934.  
  18935. A bitmap modifier is a modifier used inside an image_map, bump_map or
  18936. material_map to specify how the 2-D bitmap is to be applied to the 3-D
  18937. surface. Several bitmap modifiers apply to specific kinds of maps and they
  18938. are covered in the appropriate sections. The bitmap modifiers discussed in
  18939. the following sections are applicable to all three types of bitmaps.
  18940.  
  18941. 7.6.8.9.1        The once Option
  18942.  
  18943. Normally there are an infinite number of repeating image maps, bump maps or
  18944. material maps created over every unit square of the x-y-plane like tiles. By
  18945. adding the once keyword after a file name you can eliminate all other copies
  18946. of the map except the one at (0,0) to (1,1). In image maps, areas outside
  18947. this unit square are treated as fully transparent. In bump maps, areas
  18948. outside this unit square are left flat with no normal modification. In
  18949. material maps, areas outside this unit square are textured with the first
  18950. texture of the texture list.
  18951.  
  18952. For example:
  18953.  
  18954.   image_map {
  18955.     gif "mypic.gif"
  18956.     once
  18957.   }
  18958.  
  18959.  
  18960. 7.6.8.9.2        The "map_type" Option
  18961.  
  18962. The default projection of the bump onto the x-y-plane is called a planar map
  18963. type. This option may be changed by adding the map_type keyword followed by a
  18964. number specifying the way to wrap the bump around the object.
  18965.  
  18966. A map_type 0 gives the default planar mapping already described.
  18967.  
  18968. A map_type 1 gives a spherical mapping. It assumes that the object is a
  18969. sphere of any size sitting at the origin. The y-axis is the north/south pole
  18970. of the spherical mapping. The top and bottom edges of the bitmap just touch
  18971. the pole regardless of any scaling. The left edge of the bitmap begins at the
  18972. positive x-axis and wraps the pattern around the sphere from west to east in
  18973. a -y-rotation. The pattern covers the sphere exactly once. The once keyword
  18974. has no meaning for this type.
  18975.  
  18976. With map_type 2 you get a cylindrical mapping. It assumes that a cylinder of
  18977. any diameter lies along the y-axis. The bump pattern wraps around the
  18978. cylinder just like the spherical map but remains one unit tall from y=0 to
  18979. y=1. This band of the pattern is repeated at all heights unless the once
  18980. keyword is applied.
  18981.  
  18982. Finally map_type 5 is a torus or donut shaped mapping. It assumes that a
  18983. torus of major radius 1 sits at the origin in the x-z-plane. The pattern is
  18984. wrapped around similar to spherical or cylindrical maps. However the top and
  18985. bottom edges of the map wrap over and under the torus where they meet each
  18986. other on the inner rim.
  18987.  
  18988. Types 3 and 4 are still under development.
  18989.  
  18990. For example:
  18991.  
  18992.   sphere{<0,0,0>,1
  18993.     pigment{
  18994.       image_map {
  18995.         gif "world.gif"
  18996.         map_type 1
  18997.       }
  18998.     }
  18999.   }
  19000.  
  19001.  
  19002. 7.6.8.9.3        The interpolate Option
  19003.  
  19004. Adding the interpolate keyword can smooth the jagged look of a bitmap. When
  19005. POV-Ray asks an image map color or a bump amount for a bump map, it often
  19006. asks for a point that is not directly on top of one pixel but sort of between
  19007. several differently colored pixels. Interpolations returns an in-between
  19008. value so that the steps between the pixels in the map will look smoother.
  19009.  
  19010. Although interpolate is legal in material maps the color index is
  19011. interpolated before the texture is chosen. It does not interpolate the final
  19012. color as you might hope it would. In general, interpolation of material maps
  19013. serves no useful purpose but this may be fixed in future versions.
  19014.  
  19015. There are currently two types of interpolation:
  19016.  
  19017.   Bilinear            --- interpolate 2
  19018.   Normalized Distance --- interpolate 4
  19019.  
  19020.  
  19021. For example:
  19022.  
  19023.   image_map {
  19024.     gif "mypic.gif"
  19025.     interpolate 2
  19026.   }
  19027.  
  19028.  
  19029. Default is no interpolation. Normalized distance is the slightly faster of
  19030. the two, bilinear does a better job of picking the between color. Normally
  19031. bilinear is used.
  19032.  
  19033. If your map looks jaggy, try using interpolation instead of going to a higher
  19034. resolution image. The results can be very good.
  19035.  
  19036. 7.7              Atmospheric Effects
  19037.  
  19038. Atmospheric effects are a loosely-knit group of features that affect the
  19039. background and/or the atmosphere enclosing the scene. POV-Ray includes the
  19040. ability to render a number of atmospheric effects, such as fog, haze, mist,
  19041. rainbows and skies.
  19042.  
  19043. 7.7.1            Atmosphere
  19044.  
  19045. Important notice: The atmosphere feature in POV-Ray 3.0 are somewhat
  19046. experimental. There is a high probability that the design and implementation
  19047. of these features will be changed in future versions. We cannot guarantee
  19048. that scenes using these features in 3.0 will render identically in future
  19049. releases or that full backwards compatibility of language syntax can be
  19050. maintained.
  19051.  
  19052. Computer generated images normally assume a vacuum space that does not allow
  19053. the rendering of natural phenomena like smoke, light beams, etc. A very
  19054. simple approach to add fog to a scene is explained in section "Fog". This
  19055. kind of fog does not interact with any light sources though. It will not show
  19056. light beams or other effects and is therefore not very realistic.
  19057.  
  19058. The atmosphere effect overcomes some of the fog's limitations by calculating
  19059. the interaction between light and the particles in the atmosphere using
  19060. volume sampling. Thus shaft of light beams will become visible and objects
  19061. will cast shadows onto smoke or fog.
  19062.  
  19063. The syntax of the atmosphere is:
  19064.  
  19065.   atmosphere {
  19066.     type TYPE
  19067.     distance DISTANCE
  19068.     [ scattering SCATTERING ]
  19069.     [ eccentricity ECCENTRICITY ]
  19070.     [ samples SAMPLES ]
  19071.     [ jitter JITTER ]
  19072.     [ aa_threshold AA_THRESHOLD ]
  19073.     [ aa_level AA_LEVEL ]
  19074.     [ colour <COLOUR> ]
  19075.   }
  19076.  
  19077.  
  19078. The type keyword determines the type of scattering model to be used. There
  19079. are five different phase functions representing the different models:
  19080. isotropic, Rayleigh, Mie (haze and murky atmosphere) and Henyey-Greenstein.
  19081.  
  19082. Isotropic scattering is the simplest form of scattering because it is
  19083. independent of direction. The amount of light scattered by particles in the
  19084. atmosphere does not depend on the angle between the viewing direction and the
  19085. incoming light.
  19086.  
  19087. Rayleigh scattering models the scattering for extremely small particles such
  19088. as molecules of the air. The amount of scattered light depends on the
  19089. incident light angle. It is largest when the incident light is parallel or
  19090. anti-parallel to the viewing direction and smallest when the incident light
  19091. is perpendicular to the viewing direction. You should note that the Rayleigh
  19092. model used in POV-Ray does not take the dependency of scattering on the
  19093. wavelength into account.
  19094.  
  19095. The Rayleigh scattering function.
  19096.  
  19097. Mie scattering is used for relatively small particles such as minuscule water
  19098. droplets of fog, cloud particles, and particles responsible for the polluted
  19099. sky. In this model the scattering is extremely directional in the forward
  19100. direction i. e. the amount of scattered light is largest when the incident
  19101. light is anti-parallel to the viewing direction (the light goes directly to
  19102. the viewer). It is smallest when the incident light is parallel to the
  19103. viewing direction. The haze and murky atmosphere models differ in their
  19104. scattering characteristics. The murky model is much more directional than the
  19105. haze model.
  19106.  
  19107. The Mie "haze" scattering function.
  19108.  
  19109. The Mie "murky" scattering function.
  19110.  
  19111. The Henyey-Greenstein scattering is based on an analytical function and can
  19112. be used to model a large variety of different scattering types. The function
  19113. models an ellipse with a given eccentricity e. This eccentricity is specified
  19114. by the optional keyword eccentricity which is only used for scattering type
  19115. five. An eccentricity value of zero defines isotropic scattering while
  19116. positive values lead to scattering in the direction of the light and negative
  19117. values lead to scattering in the opposite direction of the light. Larger
  19118. values of e (or smaller values in the negative case) increase the directional
  19119. property of the scattering.
  19120.  
  19121. The Heyney-Greenstein scattering function for different eccentricity values.
  19122.  
  19123.  
  19124. The easiest way to use the different scattering types will be to declare some
  19125. constants and use those in your atmosphere definition:
  19126.  
  19127.   #declare ISOTROPIC_SCATTERING         = 1
  19128.   #declare MIE_HAZY_SCATTERING          = 2
  19129.   #declare MIE_MURKY_SCATTERING         = 3
  19130.   #declare RAYLEIGH_SCATTERING          = 4
  19131.   #declare HENYEY_GREENSTEIN_SCATTERING = 5
  19132.  
  19133.  
  19134. The distance keyword is used to determine the density of the particles in the
  19135. atmosphere. This density is constant for the whole atmosphere. The distance
  19136. parameter works in the same way as the fog distance.
  19137.  
  19138. With the scattering keyword you can change the amount of light that is
  19139. scattered by the atmosphere, thus increasing or decreasing the brightness of
  19140. the atmosphere. Smaller scattering values decrease the brightness while
  19141. larger values increase it.
  19142.  
  19143. The colour or color keyword can be used to create a colored atmosphere, i. e.
  19144. it can be used to get particles that filter the light passing through. The
  19145. default color is black.
  19146.  
  19147. The light passing through the atmosphere (either coming from light sources or
  19148. the background) is filtered by the atmosphere's color if the specified color
  19149. has a non-zero filter value. In other words, the amount by which the light is
  19150. filtered by the atmosphere's color is given by the filter value (pretty much
  19151. in the same way as it is done for the fog). Using a color of rgbf
  19152. <1,0,0,0.25> will result in a slightly reddish atmosphere because 25% of the
  19153. light passing through the atmosphere is filtered by (multiplied with) the
  19154. color of the atmosphere, i. e. rgb <1,0,0> (and that's red).
  19155.  
  19156. The transmittance channel of the atmosphere's color is used to specify a
  19157. minimum translucency. If a value larger than zero is used you'll always see
  19158. that amount of the background through the atmosphere, regardless of how dense
  19159. the atmosphere is. This works in the same way as it does for fogs.
  19160.  
  19161. Since the atmosphere is calculated by sampling along the viewing ray and
  19162. looking for contributions from light sources, it is prone to aliasing (just
  19163. like any sampling technique). There are four parameters to minimize the
  19164. artifacts that may be visible: samples, jitter, aa_level and aa_threshold.
  19165.  
  19166. The samples keyword determines how many samples are calculated in one
  19167. interval along the viewing ray. The length of the interval is either the
  19168. distance as given by the distance keyword or the length of the lit part of
  19169. the viewing ray, whichever is smaller. This lit part is a section of the ray
  19170. that
  19171. is most likely lit by a light source. In the case of a spotlight it is the
  19172. part of the ray that lies in the cone of light. In other cases it becomes
  19173. more difficult. The only thing you should keep in mind is that the actual
  19174. sampling interval length is variable but there will never be fewer than the
  19175. specified samples in the specified distance.
  19176.  
  19177. One technique to reduce the visibility of sampling artifacts is to jitter the
  19178. sample points, i. e. to add random noise to their location. This can be done
  19179. with the jitter keyword.
  19180.  
  19181. Another technique is super-sampling (an anti-aliasing method). This helps to
  19182. avoid missing features by adding additional samples in places were high
  19183. intensity changes occur (e. g. the edge of a shadow). The anti-aliasing is
  19184. turned on by the aa_level keyword. If this is larger than zero super-sampling
  19185. will be used. The additional samples will be recursively placed between two
  19186. samples with a high intensity change. The level to which subdivision takes
  19187. places is specified by the aa_level keyword. Level one means one subdivision
  19188. (one additional sample), level two means two subdivisions (up to three
  19189. additional samples), etc.
  19190.  
  19191. The threshold for the intensity change is given by the aa_threshold keyword.
  19192. If the intensity change is greater than this threshold anti-aliasing will be
  19193. used for those two samples.
  19194.  
  19195. With spotlights you'll be able to create the best results because their cone
  19196. of light will become visible. Pointlights can be used to create effects like
  19197. street lights in fog. Lights can be made to not interact with the atmosphere
  19198. by adding atmosphere off to the light source. They can be used to increase
  19199. the overall light level off the scene to make it look more realistic.
  19200.  
  19201. You should note that the atmosphere feature will not work if the camera is
  19202. inside a non-hollow object (see section "Empty and Solid Objects" for a
  19203. detailed explanation).
  19204.  
  19205. 7.7.2            Background
  19206.  
  19207. A background color can be specified if desired. Any ray that doesn't hit an
  19208. object will be colored with this color. The default background is black. The
  19209. syntax for background is:
  19210.  
  19211.   background { colour <COLOUR> }
  19212.  
  19213.  
  19214. 7.7.3            Fog
  19215.  
  19216. Fog is defined by the following statement:
  19217.  
  19218.   fog {
  19219.     fog_type FOG_TYPE
  19220.     distance DISTANCE
  19221.     colour <COLOUR>
  19222.     [ turbulence <TURBULENCE> ]
  19223.     [ turb_depth TURB_DEPTH ]
  19224.     [ omega OMEGA ]
  19225.     [ lambda LAMBDA ]
  19226.     [ octaves OCTAVES ]
  19227.     [ fog_offset FOG_OFFSET ]
  19228.     [ fog_alt FOG_ALT ]
  19229.     [ up <FOG_UP> ]
  19230.     [ TRANSFORMATION ]
  19231.   }
  19232.  
  19233.  
  19234. The optional up vector specifies a direction pointing up, generally the same
  19235. as the camera's up vector. All calculations done during the ground fog
  19236. evaluation are done relative to this up vector, i. e. the actual heights are
  19237. calculated along this vector.
  19238.  
  19239. The up vector can also be modified using any of the known transformations
  19240. described in "Transformations". Though it may not be a good idea to scale the
  19241. up vector - the results are hardly predictable - it is quite useful to be
  19242. able to rotate it. You should also note that translations do not affect the
  19243. up direction (and thus don't affect the fog).
  19244.  
  19245. Currently there are two fog types, constant fog and ground  fog. The constant
  19246. fog has a constant density everywhere while the ground fog has a constant
  19247. density for all heights below a given point on the up axis and thins out
  19248. along this axis. The height below which the fog has constant density is
  19249. specified by the fog_offset keyword. The fog_alt keyword is used to specify
  19250. the rate by which the fog fades away. At an altitude of fog_offset+fog_alt
  19251. the fog has a density of 25%. The density of the fog at a given height y is
  19252. calculated by the formula:
  19253.  
  19254.            /
  19255.            |                  1
  19256.            | -------------------------------------, y > fog_alt
  19257.            |  (1 + (y - fog_offset) / fog_alt) ^2
  19258. density = -|
  19259.            |
  19260.            |                  1,                   y <= fog_alt
  19261.            |
  19262.            \
  19263.  
  19264.  
  19265. The total density along a ray is calculated by integrating from the height of
  19266. the starting point to the height of the end point.
  19267.  
  19268. Two constants are defined for easy use of the fog types in the file
  19269. const.inc:
  19270.  
  19271.    // FOG TYPE CONSTANTS
  19272.    #declare Constant_Fog = 1
  19273.    #declare Ground_Fog   = 2
  19274.  
  19275.  
  19276. The color of a pixel with an intersection depth d is calculated by
  19277.  
  19278.   C_pixel = exp(-d/D) * C_object + (1-exp(-d/D)) * C_fog
  19279.  
  19280.  
  19281. where D is the fog distance. At depth 0 the final color is the object's
  19282. color. If the intersection depth equals the fog distance the final color
  19283. consists of 64% of the object's color and 36% of the fog's color.
  19284.  
  19285. The fog color that is given by the color keyword has three purposes. First it
  19286. defines the color to be used in blending the fog and the background. Second
  19287. it is used to specify a translucency threshold. By using a transmittance
  19288. larger than zero one can make sure that at least that amount of light will be
  19289. seen through the fog. With a transmittance of 0.3 you'll see at least 30% of
  19290. the background. Third it can be used to make a filtering fog. With a filter
  19291. value larger than zero the amount of background light given by the filer
  19292. value will be multiplied with the fog color. A filter value of 0.7 will lead
  19293. to a fog that filters 70% of the background light and leaves 30% unfiltered.
  19294.  
  19295. Fogs may be layered. That is, you can apply as many layers of fog as you
  19296. like. Generally this is most effective if each layer is a ground fog of
  19297. different color, altitude and with different turbulence values. To use
  19298. multiple layers of fogs, just add all of them to the scene.
  19299.  
  19300. You may optionally stir up the fog by adding turbulence. The turbulence
  19301. keyword may be followed by a float or vector to specify an amount of
  19302. turbulence to be used. The omega, lambda and octaves turbulence parameters
  19303. may also be specified. See section "Pattern Modifiers" for details on all of
  19304. these turbulence parameters.
  19305.  
  19306. Additionally the fog turbulence may be scaled along the direction of the
  19307. viewing ray using the turb_depth amount. Typical values are from 0.0 to 1.0
  19308. or more. The default value is 0.5 but any float value may be used.
  19309.  
  19310. You should note that the fog feature will not work if the camera is inside a
  19311. non-hollow object (see section "Empty and Solid Objects" for a detailed
  19312. explanation).
  19313.  
  19314. 7.7.4            Sky Sphere
  19315.  
  19316. The sky sphere is used create a realistic sky background without the need of
  19317. an additional sphere to simulate the sky. Its syntax is:
  19318.  
  19319.   sky_sphere {
  19320.     pigment { PIGMENT1 }
  19321.     pigment { PIGMENT2 }
  19322.     pigment { PIGMENT3 }
  19323.     ...
  19324.     [ TRANSFORMATION ]
  19325.   }
  19326.  
  19327.  
  19328. The sky sphere can contain several pigment layers with the last pigment being
  19329. at the top, i. e. it is evaluated last, and the first pigment being at the
  19330. bottom, i. e. it is evaluated first. If the upper layers contain filtering
  19331. and/or transmitting components lower layers will shine through. If not lower
  19332. layers will be invisible.
  19333.  
  19334. The sky sphere is calculated by using the direction vector as the parameter
  19335. for evaluating the pigment patterns. This leads to results independent from
  19336. the view point which pretty good models a real sky where the distance to the
  19337. sky is much larger than the distances between visible objects.
  19338.  
  19339. If you want to add a nice color blend to your background you can easily do
  19340. this by using the following example.
  19341.  
  19342.   sky_sphere {
  19343.     pigment {
  19344.       gradient y
  19345.       color_map {
  19346.         [ 0.5  color CornflowerBlue ]
  19347.         [ 1.0  color MidnightBlue ]
  19348.       }
  19349.       scale 2
  19350.       translate -1
  19351.     }
  19352.   }
  19353.  
  19354.  
  19355. This gives a soft blend from CornflowerBlue at the horizon to MidnightBlue at
  19356. the zenith. The scale and translate operations are used to map the direction
  19357. vector values, which lie in the range from <-1, -1, -1> to <1, 1, 1>, onto
  19358. the range from <0, 0, 0> to <1, 1, 1>. Thus a repetition of the color blend
  19359. is avoided for parts of the sky below the horizon.
  19360.  
  19361. In order to easily animate a sky sphere you can transform it using the known
  19362. transformations described in "Transformations". Though it may not be a good
  19363. idea to translate or scale a sky sphere - the results are hardly predictable
  19364. - it is quite useful to be able to rotate it. In an animation the color
  19365. blendings of the sky can be made to follow the rising sun for example.
  19366.  
  19367. You should note that only one sky sphere can be used in any scene. It also
  19368. will not work as you might expect if you use camera types like the
  19369. orthographic or cylindrical camera. The orthographic camera uses parallel
  19370. rays and thus you'll only see a very small part of the sky sphere (you'll get
  19371. one color skies in most cases). Reflections in curved surface will work
  19372. though, e. g. you will clearly see the sky in a mirrored ball.
  19373.  
  19374. 7.7.5            Rainbow
  19375.  
  19376. Rainbows are implemented using fog-like, circular arcs. Their syntax is:
  19377.  
  19378.   rainbow {
  19379.     direction <DIR>
  19380.     angle ANGLE
  19381.     width WIDTH
  19382.     distance DISTANCE
  19383.     color_map { COLOUR_MAP }
  19384.     [ jitter JITTER ]
  19385.     [ up <UP> ]
  19386.     [ arc_angle ARC_ANGLE ]
  19387.     [ falloff_angle FALLOFF_ANGLE ]
  19388.   }
  19389.  
  19390.  
  19391. The direction vector determines the direction of the (virtual) light that is
  19392. responsible for the rainbow. Ideally this is an infinitely far away light
  19393. source like the sun that emits parallel light rays. The position and size of
  19394. the rainbow are specified by the angle and width keywords. To understand how
  19395. they work you should first know how the rainbow is calculated.
  19396.  
  19397. For each ray the angle between the rainbow's direction vector and the ray's
  19398. direction vector is calculated. If this angle lies in the interval from
  19399. ANGLE-WIDTH/2 to ANGLE+WIDTH/2 the rainbow is hit by the ray. The color is
  19400. then determined by using the angle as an index into the rainbow's colormap.
  19401. After the color has been determined it will be mixed with the background
  19402. color in the same way like it is done for fogs.
  19403.  
  19404. Thus the angle and width parameters determine the angles under which the
  19405. rainbow will be seen. The optional jitter keyword can be used to add random
  19406. noise to the index. This adds some irregularity to the rainbow that makes it
  19407. look more realistic.
  19408.  
  19409. The distance keyword is the same like the one used with fogs. Since the
  19410. rainbow is a fog-like effect it's possible that the rainbow is noticeable on
  19411. objects. If this effect is not wanted it can be avoided by using a large
  19412. distance value. By default a sufficiently large value is used to make sure
  19413. that this effect does not occur.
  19414.  
  19415. The color_map keyword is used to assign a color map that will be mapped onto
  19416. the rainbow. To be able to create realistic rainbows it is important to know
  19417. that the index into the color map increases with the angle between the ray's
  19418. and rainbow's direction vector. The index is zero at the innermost ring and
  19419. one at the outermost ring. The filter and transmittance values of the colors
  19420. in the color map have the same meaning as the ones used with fogs (see
  19421. section "Fog").
  19422.  
  19423. The default rainbow is a 360 degree arc that looks like a circle. This is no
  19424. problem as long as you have a ground plane that hides the lower, non-visible
  19425. part of the rainbow. If this isn't the case or if you don't want the full arc
  19426. to be visible you can use the optional keywords up, arc_angle and
  19427. falloff_angle to specify a smaller arc.
  19428.  
  19429. The arc_angle keyword determines the size of the arc in degrees (from 0 to
  19430. 360 degrees). A value smaller than 360 degrees results in an arc that
  19431. abruptly vanishes. Since this doesn't look nice you can use the falloff_angle
  19432. keyword to specify a region in which the rainbow will smoothly blend into the
  19433. background making it vanish softly. The falloff angle has to be smaller or
  19434. equal to the arc angle.
  19435.  
  19436. The up keyword determines were the zero angle position is. By changing this
  19437. vector you can rotate the rainbow about its direction. You should note that
  19438. the arc goes from -ARC_ANGLE/2 to +ARC_ANGLE/2. The soft regions go from
  19439. -ARC_ANGLE/2 to -FALLOFF_ANGLE/2 and from +FALLOFF_ANGLE/2 to +ARC_ANGLE/2.
  19440.  
  19441. The following example generates a 120 degrees rainbow arc that has a falloff
  19442. region of 30 degrees at both ends:
  19443.  
  19444.   rainbow {
  19445.     direction <0, 0, 1>
  19446.     angle 42.5
  19447.     width 5
  19448.     distance 1000
  19449.     jitter 0.01
  19450.     color_map { Rainbow_Color_Map }
  19451.     up <0, 1, 0>
  19452.     arc_angle 240
  19453.     falloff_angle 60
  19454.   }
  19455.  
  19456.  
  19457. It is possible to use any number of rainbows and to combine them with other
  19458. atmospheric effects.
  19459.  
  19460. 7.8              Global Settings
  19461.  
  19462. The global_settings statement is a catch-all statement that gathers together
  19463. a number of global parameters. The statement may appear anywhere in a scene
  19464. as long as its not inside any other statement. You may have multiple
  19465. global_settings statements in a scene. Whatever values were specified in the
  19466. last global_settings statement override any previous settings. Regardless of
  19467. where you specify the statement, the feature applies to the entire scene.
  19468.  
  19469. Note that some items which were language directives in previous versions of
  19470. POV-Ray have been moved inside the global_settings statement so that it is
  19471. more obvious to the user that their effect is global. The old syntax is
  19472. permitted but generates a warning.
  19473.  
  19474.   global_settings {
  19475.     adc_bailout FLOAT
  19476.     ambient_light COLOR
  19477.     assumed_gamma FLOAT
  19478.     hf_gray_16 BOOLEAN
  19479.     irid_wavelength COLOR
  19480.     max_intersections INTEGER
  19481.     max_trace_level INTEGER
  19482.     number_of_waves INTEGER
  19483.     radiosity { RADIOSITY_ITEMS... }
  19484.   }
  19485.  
  19486.  
  19487. Each item is optional and may appear in and order. If an item is specified
  19488. more than once, the last setting overrides previous values. Details on each
  19489. item are given in the following sections.
  19490.  
  19491. 7.8.1            ADC_Bailout
  19492.  
  19493. In scenes with many reflective and transparent surfaces, POV-Ray can get
  19494. bogged down tracing multiple reflections and refractions that contribute very
  19495. little to the color of a particular pixel. The program uses a system called
  19496. Adaptive Depth Control (ADC) to stop computing additional reflected or
  19497. refracted rays when their contribution is insignificant.
  19498.  
  19499. You may use the global setting adc_bailout keyword followed by float value to
  19500. specify the point at which a ray's contribution is considered insignificant.
  19501.  
  19502.   global_settings { adc_bailout FLOAT }
  19503.  
  19504.  
  19505. The default value is 1/255, or approximately 0.0039, since a change smaller
  19506. than that could not be visible in a 24 bit image. Generally this setting is
  19507. perfectly adequate and should be left alone. Setting adc_bailout to 0 will
  19508. disable ADC, relying completely on max_trace_level to set an upper limit on
  19509. the number of rays spawned.
  19510.  
  19511. See section "Max_Trace_Level" for details on how ADC and max_trace_level
  19512. interact.
  19513.  
  19514. 7.8.2            Ambient Light
  19515.  
  19516. Ambient light is used to simulate the effect of inter-diffuse reflection that
  19517. is responsible for lighting areas that partially or completely lie in shadow.
  19518. POV-Ray provides an ambient light source to let you easily change the
  19519. brightness of the ambient lighting without changing every ambient value in
  19520. all finish statements. It also lets you create interesting effects by
  19521. changing the color of the ambient light source. The syntax is:
  19522.  
  19523.   global_settings { ambient_light COLOR }
  19524.  
  19525.  
  19526. The default is a white ambient light source set at rgb <  1,1,1>. The actual
  19527. ambient used is:    AMBIENT = FINISH_AMBIENT * GLOBAL_AMBIENT
  19528.  
  19529.  
  19530. 7.8.3            Assumed_Gamma
  19531.  
  19532. Many people may have noticed at one time or another that some images are too
  19533. bright or dim when displayed on their system. As a rule, Macintosh users find
  19534. that images created on a PC are too bright, while PC users find that images
  19535. created on a Macintosh are too dim.
  19536.  
  19537. The assumed_gamma global setting works in conjunction with the Display_Gamma
  19538. INI setting (see section "Display Hardware Settings") to ensure that scene
  19539. files render the same way across the wide variety of hardware platforms that
  19540. POV-Ray is used on. The assumed gamma setting is used in a scene file by
  19541. adding
  19542.  
  19543.   global_settings { assumed_gamma FLOAT }
  19544.  
  19545.  
  19546. where the assumed gamma value is the correction factor to be applied before
  19547. the pixels are displayed and/or saved to disk. For scenes created in older
  19548. versions of POV-Ray, the assumed gamma value will be the same as the display
  19549. gamma value of the system the scene was created on. For PC systems, the most
  19550. common display gamma is 2.2, while for scenes created on Macintosh systems
  19551. should use a scene gamma of 1.8. Another gamma value that sometimes occurs in
  19552. scenes is 1.0.
  19553.  
  19554. Scenes that do not have an assumed_gamma global setting will not have any
  19555. gamma correction performed on them, for compatibility reasons. If you are
  19556. creating new scenes or rendering old scenes, it is strongly recommended that
  19557. you put in an appropriate assumed_gamma global setting. For new scenes, you
  19558. should use an assumed gamma value of 1.0 as this models how light appears in
  19559. the real world more realistically.
  19560.  
  19561. The following sections explain more thoroughly what gamma is and why it is
  19562. important.
  19563.  
  19564. 7.8.3.1          Monitor Gamma
  19565.  
  19566. The differences in how images are displayed is a result of how a computer
  19567. actually takes an image and displays it on the monitor. In the process of
  19568. rendering an image and displaying it on the screen, several gamma values are
  19569. important, including the POV scene file or image file gamma and the monitor
  19570. gamma.
  19571.  
  19572. Most image files generated by POV-Ray store numbers in the range from 0 to
  19573. 255 for each of the red, green and blue components of a pixel. These numbers
  19574. represent the intensity of each color component, with 0 being black and 255
  19575. being the brightest color (either 100% red, 100% green or 100% blue). When an
  19576. image is displayed, the graphics card converts each color component into a
  19577. voltage which is sent to the monitor to light up the red, green and blue
  19578. phosphors on the screen. The voltage is usually proportional to the value of
  19579. each color component.
  19580.  
  19581. Gamma becomes important when displaying intensities that aren't the maximum
  19582. or minimum possible values. For example, 127 should represent 50% of the
  19583. maximum intensity for pixels stored as numbers between 0 and 255. On systems
  19584. that don't do gamma correction, 127 will be converted to 50% of the maximum
  19585. voltage, but because of the way the phosphors and the electron guns in a
  19586. monitor work, this may be only 22% of the maximum color intensity on a
  19587. monitor with a gamma of 2.2. To display a pixel which is 50% of the maximum
  19588. intensity on this monitor, we would need a voltage of 73% of the maximum
  19589. voltage, which translates to storing a pixel value of 186.
  19590.  
  19591. The relationship between the input pixel value and the displayed intensity
  19592. can be approximated by an exponential function
  19593.  
  19594.   obright = ibright ^ display_gamma
  19595.  
  19596.  
  19597. where obright is the output intensity and ibright is the input pixel
  19598. intensity. Both values are in the range from 0 to 1 (0% to 100%). Most
  19599. monitors have a fixed gamma value in the range from 1.8 to 2.6. Using the
  19600. above formula with display_gamma values greater than 1 means that the output
  19601. brightness will be less than the input brightness. In order to have the
  19602. output and input brightness be equal an overall system gamma of 1 is needed.
  19603. To do this, we need to gamma correct the input brightness in the same manner
  19604. as above but with a gamma value of 1/display_gamma before it is sent to the
  19605. monitor. To correct for a display gamma of 2.2, this pre-monitor gamma
  19606. correction uses a gamma value of 1.0/2.2 or approximately 0.45.
  19607.  
  19608. How the pre-monitor gamma correction is done depends on what hardware and
  19609. software is being used. On Macintosh systems, the operating system has taken
  19610. it upon itself to insulate applications from the differences in display
  19611. hardware. Through a gamma control panel the user may be able to set the
  19612. actual monitor gamma and MacOS will then convert all pixel intensities so
  19613. that the monitor will appear to have the specified gamma value. On Silicon
  19614. Graphics machines, the display adapter has built-in gamma correction
  19615. calibrated to the monitor which gives the desired overall gamma (the default
  19616. is 1.7). Unfortunately, on PCs and most UNIX systems, it is up to the
  19617. application to do any gamma correction needed.
  19618.  
  19619. 7.8.3.2          Image File Gamma
  19620.  
  19621. Since most PC and UNIX applications and image file formats don't understand
  19622. display gamma, they don't do anything to correct for it. As a result, users
  19623. creating images on these systems adjust the image in such a way that it has
  19624. the correct brightness when displayed. This means that the data values stored
  19625. in the files are made brighter to compensate for the darkening effect of the
  19626. monitor. In essence, the 0.45 gamma correction is built in to the image files
  19627. created and stored on these systems. When these files are displayed on a
  19628. Macintosh system, the gamma correction built in to the file, in addition to
  19629. gamma correction built into MacOS, means that the image will be too bright.
  19630. Similarly, files that look correct on Macintosh or SGI systems because of the
  19631. built-in gamma correction will be too dark when displayed on a PC.
  19632.  
  19633. The new PNG format files generated by POV-Ray 3.0 overcome the problem of too
  19634. much or not enough gamma correction by storing the image file gamma (which is
  19635. 1.0/display_gamma) inside the PNG file when it is generated by POV-Ray. When
  19636. the PNG file is later displayed by a program that has been set up correctly,
  19637. it uses this gamma value as well as the current display gamma to correct for
  19638. the potentially different display gamma used when originally creating the
  19639. image.
  19640.  
  19641. Unfortunately, of all the image file formats POV-Ray supports, PNG is the
  19642. only one that has any gamma correction features and is therefore preferred
  19643. for images that will be displayed on a wide variety of platforms.
  19644.  
  19645. 7.8.3.3          Scene File Gamma
  19646.  
  19647. The image file gamma problem itself is just a result of how scenes themselves
  19648. are generated in POV-Ray. When you start out with a new scene and are placing
  19649. light sources and adjusting surface textures and colors, you generally make
  19650. several attempts before the lighting is how you like it. How you choose these
  19651. settings depends upon the preview image or the image file stored to disk,
  19652. which in turn is dependent upon the overall gamma of the display hardware
  19653. being used.
  19654.  
  19655. This means that as the artist you are doing gamma correction in the POV-Ray
  19656. scene file for your particular hardware. This scene file will generate an
  19657. image file that is also gamma corrected for your hardware and will display
  19658. correctly on systems similar to your own. However, when this scene is
  19659. rendered on another platform, it may be too bright or too dim, regardless of
  19660. the output file format used. Rather than have you change all the scene files
  19661. to have a single fixed gamma value (heaven forbid!), POV-Ray 3.0 allows you
  19662. to specify in the scene file the display gamma of the system that the scene
  19663. was created on.
  19664.  
  19665. The assumed_gamma global setting, in conjunction with the Display_Gamma INI
  19666. setting lets POV-Ray know how to do gamma correction on a given scene so that
  19667. the preview and output image files will appear the correct brightness on any
  19668. system. Since the gamma correction is done internally to POV-Ray, it will
  19669. produce output image files that are the correct brightness for the current
  19670. display, regardless of what output format is used. As well, since the gamma
  19671. correction is performed in the high-precision data format that POV-Ray uses
  19672. internally, it produces better results than gamma correction done after the
  19673. file is written to disk.
  19674.  
  19675. Although you may not notice any difference in the output on your system with
  19676. and without an assumed_gamma setting, the assumed gamma is important if the
  19677. scene is ever rendered on another platform.
  19678.  
  19679. 7.8.4            HF_Gray_16
  19680.  
  19681. The hf_gray_16 setting is useful when using POV-Ray to generate heightfields
  19682. for use in other POV-Ray scenes. The syntax is...
  19683.  
  19684.   global_settings { hf_gray_16 BOOLEAN }
  19685.  
  19686.  
  19687. The boolean value turns the option on or off. If the keyword is specified
  19688. without the boolean value then the option is turned on. If hf_gray_16 is not
  19689. specified in any global_settings statement in the entire scene then the
  19690. default is off.
  19691.  
  19692. When hf_gray_16 is on, the output file will be in the form of a heightfield,
  19693. with the height at any point being dependent on the brightness of the pixel.
  19694. The brightness of a pixel is calculated in the same way that color images are
  19695. converted to grayscale images:
  19696.  
  19697.   height = 0.3 * red + 0.59 * green + 0.11 * blue
  19698.  
  19699.  
  19700. Setting the hf_gray_16 option will cause the preview display, if used, to be
  19701. grayscale rather than color. This is to allow you to see how the heightfield
  19702. will look because some file formats store heightfields in a way that is
  19703. difficult to understand afterwards. See section "Height Field" for a
  19704. description of how POV-Ray heightfields are stored for each file type.
  19705.  
  19706. 7.8.5            Irid_Wavelength
  19707.  
  19708. Iridescence calculations depend upon the dominant wavelengths of the primary
  19709. colors of red, green and blue light. You may adjust the values using the
  19710. global setting irid_wavelength as follows...   global_settings { irid_wavelen
  19711.  
  19712.  
  19713. The default value is rgb <0.25,0.18,0.14> and any filter or transmit values
  19714. are ignored. These values are proportional to the wavelength of light but
  19715. they represent no real world units.
  19716.  
  19717. In general, the default values should prove adequate but we provide this
  19718. option as a means to experiment with other values.
  19719.  
  19720. 7.8.6            Max_Trace_Level
  19721.  
  19722. In scenes with many reflective and transparent surfaces POV-Ray can get
  19723. bogged down tracing multiple reflections and refractions that contribute very
  19724. little to the color of a particular pixel. The global setting max_trace_level
  19725. defines the maximum number of recursive levels that POV-Ray will trace a ray.
  19726.  
  19727.  
  19728.   global_settings { max_trace_level INTEGER }
  19729.  
  19730.  
  19731. This is used when a ray is reflected or is passing through a transparent
  19732. object and when shadow rays are cast. When a ray hits a reflective surface,
  19733. it spawns another ray to see what that point reflects. That is trace level
  19734. one. If it hits another reflective surface another ray is spawned and it goes
  19735. to trace level two. The maximum level by default is five.
  19736.  
  19737. One speed enhancement added to POV-Ray in version 3.0 is Adaptive  Depth
  19738. Control (ADC). Each time a new ray is spawned as a result of reflection or
  19739. refraction its contribution to the overall color of the pixel is reduced by
  19740. the amount of reflection or the filter value of the refractive surface. At
  19741. some point this contribution can be considered to be insignificant and there
  19742. is no point in tracing any more rays. Adaptive depth control is what tracks
  19743. this contribution and makes the decision of when to bail out. On scenes that
  19744. use a lot of partially reflective or refractive surfaces this can result in a
  19745. considerable reduction in the number of rays fired and makes it safer to use
  19746. much higher max_trace_level values.
  19747.  
  19748. This reduction in color contribution is a result of scaling by the reflection
  19749. amount and/or the filter values of each surface, so a perfect mirror or
  19750. perfectly clear surface will not be optimizable by ADC. You can see the
  19751. results of ADC by watching the Rays Saved and Highest Trace Level displays on
  19752. the statistics screen.
  19753.  
  19754. The point at which a ray's contribution is considered insignificant is
  19755. controlled by the adc_bailout value. The default is 1/255 or approximately
  19756. 0.0039 since a change smaller than that could not be visible in a 24 bit
  19757. image. Generally this setting is perfectly adequate and should be left alone.
  19758. Setting adc_bailout to 0 will disable ADC, relying completely on
  19759. max_trace_level to set an upper limit on the number of rays spawned.
  19760.  
  19761. If max_trace_level is reached before a non-reflecting surface is found and if
  19762. ADC hasn't allowed an early exit from the ray tree the color is returned as
  19763. black. Raise max_trace_level if you see black areas in a reflective surface
  19764. where there should be a color.
  19765.  
  19766. The other symptom you could see is with transparent objects. For instance,
  19767. try making a union of concentric spheres with a clear texture on them. Make
  19768. ten of them in the union with radius's from 1 to 10 and render the scene. The
  19769. image will show the first few spheres correctly, then black. This is because
  19770. a new level is used every time you pass through a transparent surface. Raise
  19771. max_trace_level to fix this problem.
  19772.  
  19773. Note that raising max_trace_level will use more memory and time and it could
  19774. cause the program to crash with a stack overflow error, although ADC will
  19775. alleviate this to a large extent. Values for max_trace_level are not
  19776. restricted, so it can be set to any number as long as you have the time and
  19777. memory. However, increasing its setting does not necessarily equate to
  19778. increased image quality unless such depths are really needed by the scene.
  19779.  
  19780. 7.8.7            Max_Intersections
  19781.  
  19782. POV-Ray uses a set of internal stacks to collect ray/object intersection
  19783. points. The usual maximum number of entries in these I-Stacks is 64. Complex
  19784. scenes may cause these stacks to overflow. POV-Ray doesn't stop but it may
  19785. incorrectly render your scene. When POV-Ray finishes rendering, a number of
  19786. statistics are displayed. If you see I-Stack Overflows reported in the
  19787. statistics you should increase the stack size. Add a global setting to your
  19788. scene as follows:
  19789.  
  19790.   global_settings { max_intersections INTEGER }
  19791.  
  19792.  
  19793. 7.8.8            Number_Of_Waves
  19794.  
  19795. The wave and ripples pattern are generated by summing a series of waves, each
  19796. with a slightly different center and size. By default, ten waves are summed
  19797. but this amount can be globally controlled by changing the number_of_waves
  19798. setting.
  19799.  
  19800.   global_settings { number_of_waves INTEGER }
  19801.  
  19802.  
  19803. Changing this value affects both waves and ripples alike on all patterns in
  19804. the scene.
  19805.  
  19806. 7.8.9            Radiosity
  19807.  
  19808. Important notice: The radiosity feature in POV-Ray 3.0 are somewhat
  19809. experimental. There is a high probability that the design and implementation
  19810. of these features will be changed in future versions. We cannot guarantee
  19811. that scenes using these features in 3.0 will render identically in future
  19812. releases or that full backwards compatibility of language syntax can be
  19813. maintained.
  19814.  
  19815. Radiosity is an extra calculation that more realistically computes the
  19816. diffuse interreflection of light. This diffuse interreflection can be seen if
  19817. you place a white chair in a room full of blue carpet, blue walls and blue
  19818. curtains. The chair will pick up a blue tint from light reflecting off of
  19819. other parts of the room. Also notice that the shadowed areas of your
  19820. surroundings are not totally dark even if no light source shines directly on
  19821. the surface. Diffuse light reflecting off of other objects fills in the
  19822. shadows. Typically ray-tracing uses a trick called ambient light to simulate
  19823. such effects but it is not very accurate.
  19824.  
  19825. Radiosity is more accurate than simplistic ambient light but it takes much
  19826. longer to compute. For this reason, POV-Ray does not use radiosity by
  19827. default. Radiosity is turned on using the Radiosity INI file option or the
  19828. +QR command line switch.
  19829.  
  19830. The following sections describes how radiosity works, how to control it with
  19831. various global settings and tips on trading quality vs. speed.
  19832.  
  19833. 7.8.9.1          How Radiosity Works
  19834.  
  19835. The problem of ray-tracing is to figure out what the light level is at each
  19836. point that you can see in a scene. Traditionally, in ray tracing, this is
  19837. broken into the sum of these components:
  19838.  
  19839.   - Diffuse, the effect that makes the side of things facing the light
  19840.   - Specular, the effect that makes shiny things have dings or sparkles on
  19841.   - Ambient, the general all-over light level that any scene has, which keeps
  19842.     things in shadow from being pure black.
  19843.  
  19844.  
  19845. POV's radiosity system, based on a method by Greg Ward, provides a way to
  19846. replace the last term - the constant ambient light value - with a light level
  19847. which is based on what surfaces are nearby and how bright in turn they are.
  19848.  
  19849. The first thing you might notice about this definition is that it is
  19850. circular: the light of everything is dependent on everything else and vice
  19851. versa. This is true in real life but in the world of ray-tracing, we can make
  19852. an approximation. The approximation that is used is: the objects you are
  19853. looking at have their ambient values calculated for you by checking the other
  19854. objects nearby. When those objects are checked during this process, however,
  19855. a traditional constant ambient term is used.
  19856.  
  19857. How does POV-Ray calculate the ambient term for each point? By sending out
  19858. more rays, in many different directions, and averaging the results. A typical
  19859. point might use 200 or more rays to calculate its ambient light level
  19860. correctly.
  19861.  
  19862. Now this sounds like it would make the ray-tracer 200 times slower. This is
  19863. true, except that the software takes advantage of the fact that ambient light
  19864. levels change quite slowly (remember, shadows are calculated separately, so
  19865. sharp shadow edges are not a problem). Therefore, these extra rays are sent
  19866. out only once in a while (about 1 time in 50), then these calculated values
  19867. are saved and reused for nearby pixels in the image when possible.
  19868.  
  19869. This process of saving and reusing values is what causes the need for a
  19870. variety of tuning parameters, so you can get the scene to look just the way
  19871. you want.
  19872.  
  19873. 7.8.9.2          Adjusting Radiosity
  19874.  
  19875. As described earlier, radiosity is turned on by using the Radiosity INI file
  19876. option or the +QR command line switch. However radiosity has many parameters
  19877. that are specified in a radiosity statement inside a global_settings
  19878. statement as follows:
  19879.  
  19880.    global_settings {
  19881.      radiosity {
  19882.        brightness FLOAT
  19883.        count INTEGER
  19884.        distance_maximum FLOAT
  19885.        error_bound FLOAT
  19886.        gray_threshold FLOAT
  19887.        low_error_factor FLOAT
  19888.        minimum_reuse FLOAT
  19889.        nearest_count INTEGER
  19890.        recursion_limit INTEGER
  19891.      }
  19892.    }
  19893.  
  19894.  
  19895. Each item is optional and may appear in and order. If an item is specified
  19896. more than once the last setting overrides previous values. Details on each
  19897. item is given in the following sections.
  19898.  
  19899. 7.8.9.2.1        brightness
  19900.  
  19901. This is the degree to which ambient values are brightened before being
  19902. returned upwards to the rest of the system. If an object is red < 1, 0, 0>,
  19903. with an ambient value of 0.3, in normal situations a red component of 0.3
  19904. will be added in. With radiosity on, assume it was surrounded by an object of
  19905. gra color <0.6, 0.6, 0.6>. The average color returned by the gathering
  19906. process will be the same. This will be multiplied by the texture's ambient
  19907. weight value of 0.3, returning <0.18, 0.18, 0.18>. This is much darker than
  19908. the 0.3 which would be added in normally. Therefore, all returned values are
  19909. brightened by the inverse of the average of the calculated values, so the
  19910. average ambient added in does not change. Some will be higher than specified
  19911. (higher than 0.3 in this example) and some will be lower but the overall
  19912. scene brightness will be unchanged.
  19913.  
  19914.  
  19915. 7.8.9.2.2        count
  19916.  
  19917. The number of rays that are sent out whenever a new radiosity value has to be
  19918. calculated is given by count. Values of 100 to 150 make most scenes look
  19919. good. Higher values might be needed for scenes with high contrast between
  19920. light levels or small patches of light causing the illumination. This would
  19921. be used only for a final rendering on an image because it is very compute
  19922. intensive. Since most scenes calculate the ambient value at 1% to 2% of
  19923. pixels, as a rough estimate, your rendering will take 1% to 2% of this number
  19924. times as long. If you set it to 300 your rendering might take 3 to 6 times as
  19925. long to complete (1% to 2% times 300).
  19926.  
  19927. When this value is too low, the light level will tend to look a little bit
  19928. blotchy, as if the surfaces you're looking at were slightly warped. If this
  19929. is not important to your scene (as in the case that you have a bump map or if
  19930. you have a strong texture) then by all means use a lower number.
  19931.  
  19932.  
  19933. 7.8.9.2.3        distance_maximum
  19934.  
  19935. The distance_maximum is the only tuning value that depends upon the size of
  19936. the objects in the scene. This one must be set for scenes to render
  19937. properly... the rest can be ignored for a first try. It is difficult to
  19938. describe the meaning simply but it sets the distance in model units from a
  19939. sample at which the error is guaranteed to hit 100% (radiosity_error_bound
  19940. >=1): no samples are reused at a distance larger than this from their
  19941. original calculation point.
  19942.  
  19943. Imagine an apple at the left edge of a table. The goal is to make sure that
  19944. samples on the surface of the table at the right are not used too close to
  19945. the apple and definitely not underneath the apple. If you had enough rays
  19946. there wouldn't be a problem since one of them would be guaranteed to hit the
  19947. apple and set the reuse radius properly for you. In practice, you must limit
  19948. this.
  19949.  
  19950. We use this technique: find the object in your scene which might have the
  19951. following problem: a small object on a larger flatter surface that you want
  19952. good ambient light near. Now, how far from this would you have to get to be
  19953. sure that one of your rays had a good chance of hitting it? In the
  19954. apple-on-the-table example, assuming I used one POV-Ray unit as one inch, I
  19955. might use 30 inches. A theoretically sound way (when you are running lots of
  19956. rays) is the distance at which this object's top is 5 degrees above the
  19957. horizon of the sample point you are considering. This corresponds to about 11
  19958. times the height of the object. So, for a 3-inch apple, 33 inches makes some
  19959. sense. For good behavior under and around a 1/3 inch pea, use 3 inches etc.
  19960. Another VERY rough estimate is one third the distance from your eye position
  19961. to the point you are looking at. The reasoning is that you are probably no
  19962. more than 90 inches from the apple on the table, if you care about the
  19963. shading underneath it.
  19964.  
  19965.  
  19966. 7.8.9.2.4        error_bound
  19967.  
  19968. The error_bound is one of the two main speed/quality tuning values (the other
  19969. is of course the number of rays shot). In an ideal world, this would be the
  19970. only value needed. It is intended to mean the fraction of error tolerated.
  19971. For example, if it were set to 1 the algorithm would not calculate a new
  19972. value until the error on the last one was estimated at as high as 100%.
  19973. Ignoring the error introduced by rotation for the moment, on flat surfaces
  19974. this is equal to the fraction of the reuse distance, which in turn is the
  19975. distance to the closest item hit. If you have an old sample on the floor 10
  19976. inches from a wall, an error bound of 0.5 will get you a new sample at a
  19977. distance of about 5 inches from the wall. 0.5 is a little rough and ready,
  19978. 0.33 is good for final renderings. Values much lower than 0.3 take forever.
  19979.  
  19980.  
  19981. 7.8.9.2.5        gray_threshold
  19982.  
  19983. Diffusely interreflected light is a function of the objects around the point
  19984. in question. Since this is recursively defined to millions of levels of
  19985. recursion, in any real life scene, every point is illuminated at least in
  19986. part by every other part of the scene. Since we can't afford to compute this,
  19987. we only do one bounce and the calculated ambient light is very strongly
  19988. affected by the colors of the objects near it. This is known as color bleed
  19989. and it really happens but not as much as this calculation method would have
  19990. you believe. The gray_threshold variable grays it down a little, to make your
  19991. scene more believable. A value of .6 means to calculate the ambient value as
  19992. 60% of the equivalent gray value calculated, plus 40% of the actual value
  19993. calculated. At 0%, this feature does nothing. At 100%, you always get
  19994. white/gray ambient light, with no hue. Note that this does not change the
  19995. lightness/darkness, only the strength of hue/grayness (in HLS terms, it
  19996. changes H only).
  19997.  
  19998.  
  19999. 7.8.9.2.6        low_error_factor
  20000.  
  20001. If you calculate just enough samples, but no more, you will get an image
  20002. which has slightly blotchy lighting. What you want is just a few extra
  20003. interspersed, so that the blending will be nice and smooth. The solution to
  20004. this is the mosaic preview: it goes over the image one or more times
  20005. beforehand, calculating radiosity values. To ensure that you get a few extra,
  20006. the radiosity algorithm lowers the error bound during the pre-final passes,
  20007. then sets it back just before the final pass. This tuning value sets the
  20008. amount that the error bound is dropped during the preliminary image passes.
  20009. If your low error factor is 0.8 and your error bound is set to 0.4 it will
  20010. really use an error bound of 0.32 during the first passes and 0.4 on the
  20011. final pass.
  20012.  
  20013.  
  20014. 7.8.9.2.7        minimum_reuse
  20015.  
  20016. The minimum effective radius ratio is set by minimum_reuse. This is the
  20017. fraction of the screen width which sets the minimum radius of reuse for each
  20018. sample point (actually, it is the fraction of the distance from the eye but
  20019. the two are roughly equal). For example, if the value is 0.02 the radius of
  20020. maximum reuse for every sample is set to whatever ground distance corresponds
  20021. to 2% of the width of the screen. Imagine you sent a ray off to the horizon
  20022. and it hits the ground at a distance of 100 miles from your eyepoint. The
  20023. reuse distance for that sample will be set to 2 miles. At a resolution of
  20024. 300*400 this will correspond to (very roughly) 8 pixels. The theory is that
  20025. you don't want to calculate values for every pixel into every crevice
  20026. everywhere in the scene, it will take too long. This sets a minimum bound for
  20027. the reuse. If this value is too low, (which is should be in theory) rendering
  20028. gets slow, and inside corners can get a little grainy. If it is set too high,
  20029. you don't get the natural darkening of illumination near inside edges, since
  20030. it reuses. At values higher than 2% you start getting more just plain errors,
  20031. like reusing the illumination of the open table underneath the apple.
  20032.  
  20033. Remember that this is a unitless ratio.
  20034.  
  20035.  
  20036. 7.8.9.2.8        nearest_count
  20037.  
  20038. The nearest_count value is the maximum number of old ambient values blended
  20039. together to create a new interpolated value. It will always be the n
  20040. geometrically closest reusable points that get used. If you go lower than 4,
  20041. things can get pretty patchy. This can be good for debugging, though. Must be
  20042. no more than 10, since that is the size of the array allocated.
  20043.  
  20044.  
  20045. 7.8.9.2.9        radiosity_quality
  20046.  
  20047.  
  20048. 7.8.9.2.10       recursion_limit
  20049.  
  20050. This value determines how many recursion levels are used to calculate the
  20051. diffuse inter-reflection. Valid values are one and two.
  20052.  
  20053.  
  20054. 7.8.9.3          Tips on Radiosity
  20055.  
  20056. If you want to see where your values are being calculated set radiosity_count
  20057. down to about 20, set radiosity_nearest_count to 1 and set radiosity_gray to
  20058. 0. This will make everything maximally patchy, so you'll be able to see the
  20059. borders between patches. There will have been a radiosity calculation at the
  20060. center of most patches. As a bonus, this is quick to run. You can then change
  20061. the radiosity_error_bound up and down to see how it changes things. Likewise
  20062. modify radiosity_reuse_dist_min and max.
  20063.  
  20064. One way to get extra smooth results: crank up the sample count (we've gone as
  20065. high as 1300) and drop the low_error_factor to something small like 0.6. Bump
  20066. up the reuse_count to 7 or 8. This will get better values, and more of them,
  20067. then interpolate among more of them on the last pass. This is not for people
  20068. with a lack of patience since it is like a squared function. If your
  20069. blotchiness is only in certain corners or near certain objects try tuning the
  20070. error bound instead. Never drop it by more than a little at a time, since the
  20071. run time will get very long.
  20072.  
  20073. If your scene looks good but right near some objects you get spots of the
  20074. right (usually darker) color showing on a flat surface of the wrong color
  20075. (same as far away from the object), then try dropping reuse_dist_max. If that
  20076. still doesn't work well increase your ray count by 100 and drop the error
  20077. bound just a bit. If you still have problems, drop reuse_nearest_count to
  20078. about 4.
  20079.  
  20080. APPENDIX A       Copyright
  20081.  
  20082. The following sections contain the legal information and license for the
  20083. Persistence of Vision(tm) Ray-Tracer, also called POV-Ray(tm).
  20084.  
  20085.  
  20086. APPENDIX A.1     General License Agreement
  20087.  
  20088. THIS NOTICE MUST ACCOMPANY ALL OFFICIAL OR CUSTOM PERSISTENCE OF  VISION
  20089. FILES. IT MAY NOT BE REMOVED OR MODIFIED. THIS INFORMATION  PERTAINS TO ALL
  20090. USE OF THE PACKAGE WORLDWIDE. THIS DOCUMENT  SUPERSEDES ALL PREVIOUS GENERAL
  20091. LICENSES OR DISTRIBUTION POLICIES.  ANY INDIVIDUALS, COMPANIES OR GROUPS WHO
  20092. HAVE BEEN GRANTED SPECIAL  LICENSES MAY CONTINUE TO DISTRIBUTE VERSION 2.x
  20093. BUT MUST RE-APPLY  FOR VERSION 3.00 OR LATER.
  20094.  
  20095. This document pertains to the use and distribution of the Persistence of
  20096. Vision(tm) Ray-Tracer a. k. a POV-Ray(tm). It applies to all POV-Ray program
  20097. source files, executable (binary) files, scene files, documentation files,
  20098. help file, bitmaps and INI files contained in official POV-Ray Team(tm)
  20099. archives. All of these are referred to here as the software.
  20100.  
  20101. All of this software is Copyright 1991,1997 by the POV-Ray Team(tm). Although
  20102. it is distributed as freeware, it is NOT Public Domain.
  20103.  
  20104. The copyrighted package may ONLY be distributed and/or modified according to
  20105. the license granted herein. The spirit of the license is to promote POV-Ray
  20106. as a standard ray-tracer, provide the full POV-Ray package freely to as many
  20107. users as possible, prevent POV-Ray users and developers from being taken
  20108. advantage of, enhance the life quality of those who come in contact with
  20109. POV-Ray. This license was created so these goals could be realized. You are
  20110. legally bound to follow these rules, but we hope you will follow them as a
  20111. matter of ethics, rather than fear of litigation.
  20112.  
  20113. APPENDIX A.2     Usage Provisions
  20114.  
  20115. Permission is granted to the user to use the software and associated files in
  20116. this package to create and render images. The use of this software for the
  20117. purpose of creating images is completely free. The creator of a scene file
  20118. and the image created from the scene file, retains all rights to the image
  20119. and scene file they created and may use them for any purpose commercial or
  20120. noncommercial.
  20121.  
  20122. The user is also granted the right to use the scenes files, fonts, bitmaps,
  20123. and include files distributed in the include, texsamps and pov3demo sub-
  20124. directories in their own scenes. Such permission does not extend to files in
  20125. the povscn sub-directory. povscn files are for your enjoyment and education
  20126. but may not be the basis of any derivative works.
  20127.  
  20128. APPENDIX A.3     General Rules for All Distributions
  20129.  
  20130. The permission to distribute this package under certain very specific
  20131. conditions is granted in advance, provided that the following conditions are
  20132. met.
  20133.  
  20134. These archives must not be re-archived using a different method without the
  20135. explicit permission of the POV-Team. You may rename the archives only to meet
  20136. the file name conventions of your system or to avoid file name duplications
  20137. but we ask that you try to keep file names as similar to the originals as
  20138. possible (for example: povsrc.zip to povsrc30.zip)
  20139.  
  20140. Ready-to-run unarchived distribution on CD-ROM is also permitted if the files
  20141. are arranged in our standard directory or folder structure as though it had
  20142. been properly installed on a hard disk.
  20143.  
  20144. You must distribute a full package of files as described in the next section.
  20145. No portion of this package may be separated from the package and distributed
  20146. separately other than under the conditions specified in the provisions given
  20147. below.
  20148.  
  20149. Non-commercial distribution in which no money or compensation is charged
  20150. (such as a user copying the software for a personal friend or colleague) is
  20151. permitted with no other restrictions.
  20152.  
  20153. Teachers and educational institutions may also distribute the material to
  20154. students and may charge minimal copying costs if the software is to be used
  20155. in a course.
  20156.  
  20157. APPENDIX A.4     Definition of "Full Package"
  20158.  
  20159. POV-Ray is contained in two sets of archives for each hardware platform. A
  20160. full package consists of either:
  20161.  
  20162. 1) End user executable archives containing an executable program,
  20163. documentation, and sample scenes but no source.
  20164.  
  20165. - or -
  20166.  
  20167. 2) Programmer archives containing full source code but no executable.  Also
  20168. you must include an archive containing documentation, and  sample scenes. On
  20169. some platforms, the documentation and sample  scenes are archived separately
  20170. from the source. Source alone  is not sufficient. You must have docs and
  20171. scenes.
  20172.  
  20173. POV-Ray is officially distributed for MS-Dos; Windows 32-bit; Linux for Intel
  20174. x86 series; Apple Macintosh; Apple PowerPC; SunOS; and Amiga. Other systems
  20175. may be added in the future.
  20176.  
  20177. Distributors need not support all platforms but for each platform you support
  20178. you must distribute a full package. For example a Macintosh only BBS need not
  20179. distribute the Windows versions.
  20180.  
  20181. This software may only be bundled with other software packages according to
  20182. the conditions specified in the provisions below.
  20183.  
  20184. {/HEADER 1 Conditions for Shareware/Freeware Distribution Companies/}
  20185.  
  20186. Shareware and freeware distribution companies may distribute the software
  20187. included in software-only compilations using media such as, but not limited
  20188. to, floppy disk, CD-ROM, tape backup, optical disks, hard disks, or memory
  20189. cards. This section only applies to distributors of collected programs.
  20190. Anyone wishing to bundle the package with a shareware product must use the
  20191. commercial bundling rules. Any bundling with books, magazines or other print
  20192. media should also use the commercial rules.
  20193.  
  20194. You must notify us that you are distributing POV-Ray and must provide us with
  20195. information on how to contact you should any support issues arise.
  20196.  
  20197. No more than five dollars U.S. ($5) can be charged per disk for the copying
  20198. of this software and the media it is provided on. Space on each disk must be
  20199. used as fully as possible. You may not spread the files over more disks than
  20200. are necessary.
  20201.  
  20202. Distribution on high volume media such as backup tape or CD-ROM is permitted
  20203. if the total cost to the user is no more than $0.08 U.S. dollars per megabyte
  20204. of data. For example a CD-ROM with 600 meg could cost no more than $48.00.
  20205.  
  20206. APPENDIX A.5     Conditions for On-Line Services and BBS's Including Internet
  20207.  
  20208.  
  20209. On-line services, BBS's and internet sites may distribute the POV-Ray
  20210. software under the conditions in this section. Sites which allow users to run
  20211. POV-Ray from remote locations must use separate provisions in the section
  20212. below.
  20213.  
  20214. The archives must all be easily available on the service and should be
  20215. grouped together in a similar on-line area.
  20216.  
  20217. It is strongly requested that sites remove prior versions of POV-Ray to avoid
  20218. user confusion and simplify or minimize our support efforts.
  20219.  
  20220. The site may only charge standard usage rates for the downloading of this
  20221. software. A premium may not be charged for this package. I. e. CompuServe or
  20222. America On-Line may make these archives available to their users, but they
  20223. may only charge regular usage rates for the time required to download.
  20224.  
  20225. APPENDIX A.6     Online or Remote Execution of POV-Ray
  20226.  
  20227. Some internet sites have been set up so that remote users can actually run
  20228. POV-Ray software on the internet server. Other companies sell CPU time for
  20229. running POV-Ray software on workstations or high-speed computers. Such use of
  20230. POV-Ray software is permitted under the following conditions.
  20231.  
  20232. Fees or charges, if any, for such services must be for connect time, storage
  20233. or processor usage ONLY. No premium charges may be assessed for use of
  20234. POV-Ray beyond that charged for use of other software. Users must be clearly
  20235. notified that they are being charged for use of the computer and not for use
  20236. of POV-Ray software.
  20237.  
  20238. Users must be prominently informed that they are using POV-Ray software, that
  20239. such software is free, and where they can find official POV-Ray software. Any
  20240. attempt to obscure the fact that the user is running POV-Ray is expressly
  20241. prohibited.
  20242.  
  20243. All files normally available in a full package distribution, especially a
  20244. copy of this license and full documentation must be available for download or
  20245. readable online so that users of an online executable have access to all of
  20246. the material of a full user package.
  20247.  
  20248. If the POV-Ray software has been modified in any way, it must also follow the
  20249. provisions for custom versions below.
  20250.  
  20251. APPENDIX A.7     Conditions for Distribution of Custom Versions
  20252.  
  20253. The user is granted the privilege to modify and compile the source code for
  20254. their own personal use in any fashion they see fit. What you do with the
  20255. software in your own home is your business.
  20256.  
  20257. If the user wishes to distribute a modified version of the software,
  20258. documentation or other parts of the package (here after referred to as a
  20259. custom version) they must follow the provisions given below. This includes
  20260. any translation of the documentation into other languages or other file
  20261. formats. These license provisions have been established to promote the growth
  20262. of POV-Ray and prevent difficulties for users and developers alike. Please
  20263. follow them carefully for the benefit of all concerned when creating a custom
  20264. version.
  20265.  
  20266. No portion of the POV-Ray source code may be incorporated into another
  20267. program unless it is clearly a custom version of POV-Ray that includes all of
  20268. the basic functions of POV-Ray.
  20269.  
  20270. All executables, documentation, modified files and descriptions of the same
  20271. must clearly identify themselves as a modified and unofficial version of
  20272. POV-Ray. Any attempt to obscure the fact that the user is running POV-Ray or
  20273. to obscure that this is an unofficial version expressly prohibited.
  20274.  
  20275. You must provide all POV-Ray support for all users who use your custom
  20276. version. You must provide information so that user may contact you for
  20277. support for your custom version. The POV-Ray Team is not obligated to provide
  20278. you or your users any technical support.
  20279.  
  20280. Include contact information in the DISTRIBUTION_MESSAGE macros in the source
  20281. file optout.h and insure that the program prominently displays this
  20282. information. Display all copyright notices and credit screens for the
  20283. official version.
  20284.  
  20285. Custom versions may only be distributed as freeware. You must make all of
  20286. your modifications to POV-Ray freely and publicly available with full source
  20287. code to the modified portions of POV-Ray and must freely distribute full
  20288. source to any new parts of the custom version. The goal is that users must be
  20289. able to re-compile the program themselves and to be able to further improve
  20290. the program with their own modifications.
  20291.  
  20292. You must provide documentation for any and all modifications that you have
  20293. made to the program that you are distributing. Include clear and obvious
  20294. information on how to obtain the official POV-Ray.
  20295.  
  20296. The user is encouraged to send enhancements and bug fixes to the POV-Ray
  20297. Team, but the team is in no way required to utilize these enhancements or
  20298. fixes. By sending material to the team, the contributor asserts that he owns
  20299. the materials or has the right to distribute these materials. He authorizes
  20300. the team to use the materials any way they like. The contributor still
  20301. retains rights to the donated material, but by donating, grants unrestricted,
  20302. irrevocable usage and distribution rights to the POV-Ray Team. The team
  20303. doesn't have to use the material, but if we do, you do not acquire any rights
  20304. related to POV-Ray. The team will give you credit as the creator of new code
  20305. if applicable.
  20306.  
  20307.  
  20308. APPENDIX A.8     Conditions for Commercial Bundling
  20309.  
  20310. Vendors wishing to bundle POV-Ray with commercial software (including
  20311. shareware) or with publications must first obtain explicit permission from
  20312. the POV-Ray Team. This includes any commercial software or publications, such
  20313. as, but not limited to, magazines, cover-disk distribution, books,
  20314. newspapers, or newsletters in print or machine readable form.
  20315.  
  20316. The POV-Ray Team will decide if such distribution will be allowed on a
  20317. case-by-case basis and may impose certain restrictions as it sees fit. The
  20318. minimum terms are given below. Other conditions may be imposed.
  20319.  
  20320.   * Purchasers of your product must not be led to believe that they are
  20321.     paying for POV-Ray. Any mention of the POV-Ray bundle on the box, in
  20322.     advertising or in instruction manuals must be clearly marked with a
  20323.     disclaimer that POV-Ray is free software and can be obtained for free or
  20324.   * Include clear and obvious information on how to obtain the official
  20325.   * You must provide all POV-Ray support for all users who acquired POV-Ray
  20326.     through your product. The POV-Ray Development Team is not obligated to
  20327.   * If you modify any portion POV-Ray for use with your hardware or software,
  20328.   * Include a full user package as described above.r product.hese rules.
  20329.  
  20330. APPENDIX A.9     Retail Value of this Software
  20331.  
  20332. Although POV-Ray is, when distributed within the terms of this agreement,
  20333. free of charge, the retail value (or price) of this program is determined as
  20334. US$20.00 per copy distributed or copied. If the software is distributed or
  20335. copied without authorization you are legally liable to this debt to the
  20336. copyright holder or any other person or organization delegated by the
  20337. copyright holder for the collection of this debt, and you agree that you are
  20338. legally bound by the above and will pay this debt within 30 days of the
  20339. event.
  20340.  
  20341. However, none of the above paragraph constitutes permission for you to
  20342. distribute this software outside of the terms of this agreement. In
  20343. particular, the conditions and debt mentioned above (whether paid or unpaid)
  20344. do not allow you to avoid statutory damages or other legal penalties and does
  20345. not constitute any agreement that would allow you to avoid such other legal
  20346. remedies as are available to the copyright holder.
  20347.  
  20348. Put simply, POV-Ray is only free if you comply with our distribution
  20349. conditions; it is not free otherwise. The copyright holder of this software
  20350. chooses to give it away free under these and only these conditions.
  20351.  
  20352. For the purpose of copyright regulations, the retail value of this software
  20353. is US$20.00 per copy.
  20354.  
  20355. APPENDIX A.10    Other Provisions
  20356.  
  20357. The team permits and encourages the creation of programs, including
  20358. commercial packages, which import, export or translate files in the POV-Ray
  20359. Scene Description Language. There are no restrictions on use of the language
  20360. itself. We reserve the right to add or remove or change any part of the
  20361. language.
  20362.  
  20363. "POV-Ray", "Persistence of Vision", "POV-Ray Team" and "POV-Help" are
  20364. trademarks of the POV-Ray Team.
  20365.  
  20366. While we do not claim any restrictions on the letters "POV" alone, we humbly
  20367. request that you not use POV in the name of your product. Such use tends to
  20368. imply it is a product of the POV-Ray Team. Existing programs which used "POV"
  20369. prior to the publication of this document need not feel guilty for doing so
  20370. provided that you make it clear that the program is not the work of the team
  20371. nor endorsed by us.
  20372.  
  20373. APPENDIX A.11    Revocation of License
  20374.  
  20375. VIOLATION OF THIS LICENSE IS A VIOLATION OF COPYRIGHT LAWS. IT  WILL RESULT
  20376. IN REVOCATION OF ALL DISTRIBUTION PRIVILEGES AND MAY  RESULT IN CIVIL OR
  20377. CRIMINAL PENALTY.
  20378.  
  20379. Such violators who are prohibited from distribution will be identified in
  20380. this document.
  20381.  
  20382. In this regard, "PC Format", a magazine published by Future Publishing, Ltd.
  20383. in the United Kingdom, distributed incomplete versions of POV-Ray 1.0 in
  20384. violation the license which was effect at the time. They later attempted to
  20385. distribute POV-Ray 2.2 without prior permission of the POV-Ray Team in
  20386. violation the license which was in effect at the time. There is evidence that
  20387. other Future Publishing companies have also violated our terms. Therefore "PC
  20388. Format", and any other magazine, book or CD-ROM publication owned by Future
  20389. Publishing is expressly prohibited from any distribution of POV-Ray software
  20390. until further notice.
  20391.  
  20392. APPENDIX A.12    Disclaimer
  20393.  
  20394. This software is provided as is without any guarantees or warranty. Although
  20395. the authors have attempted to find and correct any bugs in the package, they
  20396. are not responsible for any damage or losses of any kind caused by the use or
  20397. misuse of the package. The authors are under no obligation to provide
  20398. service, corrections, or upgrades to this package.
  20399.  
  20400. APPENDIX A.13    Technical Support
  20401.  
  20402. We sincerely hope you have fun with our program. If you have any problems
  20403. with the program, the team would like to hear about them. Also, if you have
  20404. any comments, questions or enhancements, please contact the POV-Ray Team in
  20405. out own forum on the CompuServe Information Service, the GO POVRAY forum.
  20406. Also check us out on the internet at http://www.povray.org or ftp.povray.org.
  20407. The USENET group comp.graphics.rendering.raytracing is a great source of
  20408. information on POV-Ray and related topics.
  20409.  
  20410. License enquiries should be made via email and limited technical support is
  20411. available via email to:
  20412.  
  20413.    Chris Young
  20414.    POV-Ray Team Coordinator
  20415.    CIS: 76702,1655
  20416.    Internet 76702.1655@compuserve.com
  20417.  
  20418.  
  20419. The following postal address is only for official license business and only
  20420. if email is impossible.
  20421.  
  20422. We do not provide technical support via regular mail, only email. We don't
  20423. care if you don't have a modem or online access. We will not mail you disks
  20424. with updated versions. Do not send money.
  20425.  
  20426.    Chris Young
  20427.    3119 Cossell Drive
  20428.    Indianapolis, IN 46224 U.S.A.
  20429.  
  20430.  
  20431. The other authors' contact information may be found in section "Authors"
  20432. (see also "Postcards for POV-Ray Team Members").
  20433.  
  20434. APPENDIX B       Authors
  20435.  
  20436. Following is a list in alphabetic order of all people who have ever worked on
  20437. the POV-Ray Team or who have made a note-worthy contribution. If you want to
  20438. contact or thank the authors read the sections "Contacting the Authors" and
  20439. "Postcards for POV-Ray Team Members".
  20440.  
  20441.                                Claire Amundsen
  20442.                    (Tutorials for the POV-Ray User Guide)
  20443.  
  20444.                                  Steve Anger
  20445.                          (POV-Ray 2.0/3.0 developer)
  20446.                                CIS: 70714,3113
  20447.                          Internet: sanger@hookup.net
  20448.  
  20449.                                 Randy Antler
  20450.                      (IBM-PC display code enhancements)
  20451.  
  20452.                                  John Baily
  20453.                               (RLE targa code)
  20454.  
  20455.                                  Eric Barish
  20456.                               (Ground fog code)
  20457.  
  20458.                                 Dieter Bayer
  20459.                 (POV-Ray 3.0 developer and docs coordinator)
  20460.                                CIS: 104707,643
  20461.  
  20462.                                Kendall Bennett
  20463.                            (PMODE library support)
  20464.  
  20465.                                 Steve Bennett
  20466.                                 (GIF support)
  20467.  
  20468.                               Jeff Bowermaster
  20469.                                  (Beta test)
  20470.  
  20471.                                  David Buck
  20472.                         (Original author of DKBTrace)
  20473.                            (POV-Ray 1.0 developer)
  20474.  
  20475.                                  Chris Cason
  20476.          (POV-Ray 2.0/3.0 developer, POV-Help, POV-Ray for Windows)
  20477.    Internet (preferred): povray@mail.oaks.com.au or Chris.Cason@povray.org
  20478.                               CIS: 104706,3166
  20479.  
  20480.                                 Aaron Collins
  20481.                         (Co-author of DKBTrace 2.12)
  20482.                            (POV-Ray 1.0 developer)
  20483.  
  20484.                                 Chris Dailey
  20485.                            (POV-Ray 3.0 developer)
  20486.                                     CIS:
  20487.  
  20488.                                 Steve Demlow
  20489.                            (POV-Ray 3.0 developer)
  20490.                                     CIS:
  20491.  
  20492.                                Andreas Dilger
  20493.                            (POV-Ray 3.0 developer)
  20494.                      Internet: adilger@enel.ucalgary.ca
  20495.            WWW: http://www-mddsp.enel.ucalgary.ca/People/adilger/
  20496.  
  20497.                            Joris van Drunen Littel
  20498.                               (Mac beta tester)
  20499.  
  20500.                               Alexander Enzmann
  20501.                        (POV-Ray 1.0/2.0/3.0 developer)
  20502.                                CIS: 70323,2461
  20503.                          Internet: xander@mitre.com
  20504.  
  20505.                                  Dan Farmer
  20506.                        (POV-Ray 1.0/2.0/3.0 developer)
  20507.                                CIS: 74431,1075
  20508.  
  20509.                                Charles Fusner
  20510.                    (Tutorials for the POV-Ray User Guide)
  20511.  
  20512.                                  David Harr
  20513.                      (Mac balloon help and palette code)
  20514.  
  20515.                                  Jimmy Hoeks
  20516.                    (Help file for Windows user interface)
  20517.  
  20518.                                 Terry Kanakis
  20519.                                 (Camera fix)
  20520.  
  20521.                             Kari Juharvi Kivisalo
  20522.                               (Ground fog code)
  20523.  
  20524.                                  Adam Knight
  20525.                 (Mac beta tester, Mac Apple Guide developer)
  20526.                                     CIS:
  20527.  
  20528.                               Lutz Kretzschmar
  20529.    (IBM-PC display code [SS24 truecolor], part of the anti-aliasing code)
  20530.                               CIS: 100023,2006
  20531.  
  20532.                               Charles Marslett
  20533.                             (IBM-PC display code)
  20534.  
  20535.                               Pascal Massimino
  20536.                               (Fractal objects)
  20537.  
  20538.                                 Jim McElhiney
  20539.                            (POV-Ray 3.0 developer)
  20540.                                     CIS:
  20541.  
  20542.                              Robert A. Mickelsen
  20543.                              (POV-Ray 3.0 docs)
  20544.                                CIS: 71042,751
  20545.                           internet email: ram@iu.net
  20546.                         WWW: www.websharx.com/~kahuna
  20547.  
  20548.                                  Mike Miller
  20549.                       (Artist, scene files, stones.inc)
  20550.                                CIS: 70353,100
  20551.  
  20552.                                 Douglas Muir
  20553.                          (Bump maps, height fields)
  20554.  
  20555.                                 Joel NewKirk
  20556.                                (Amiga Version)
  20557.                               CIS: 102627,1152
  20558.  
  20559.                                 Jim Nitchals
  20560.                          (Mac version, scene files)
  20561.  
  20562.                                  Paul Novak
  20563.  
  20564.                            (Texture contributions)
  20565.  
  20566.                                   Dave Park
  20567.                        (Amiga support, AGA video code)
  20568.  
  20569.                                  David Payne
  20570.                               (RLE targa code)
  20571.  
  20572.                                  Bill Pulver
  20573.                          (Time code, IBM-PC compile)
  20574.  
  20575.                                  Anton Raves
  20576.              (Beta tester, helping out on several Mac thingies)
  20577.                               CIS: 100022,2603
  20578.  
  20579.                                Dan Richardson
  20580.                                    (Docs)
  20581.                                     CIS:
  20582.  
  20583.                                  Tim Rowley
  20584.              (PPM and Windows-specific BMP image format support)
  20585.                        Internet: trowley@geom.umn.edu
  20586.  
  20587.                               Robert Schadewald
  20588.                                 (Beta tester)
  20589.                                     CIS:
  20590.  
  20591.                                 Eduard Schwan
  20592.                      (Mac version, mosaic preview, docs)
  20593.                    CIS: 104706,3276 or POVRAYMAC or ESPSW
  20594.          Internet: povraymac@compuserve.com or espsw@compuserve.com
  20595.            WWW: http://ourworld.compuserve.com/homepages/povraymac
  20596.  
  20597.                                Robert Skinner
  20598.                               (Noise functions)
  20599.  
  20600.                               Erkki Sondergaard
  20601.                                 (Scene files)
  20602.                                     CIS:
  20603.  
  20604.                                Zsolt Szalavari
  20605.                                  (Halo code)
  20606.                        Internet: zsolt@cg.tuwien.ac.at
  20607.  
  20608.                                 Scott Taylor
  20609.                         (Leopard and onion textures)
  20610.  
  20611.                                Timothy Wegner
  20612.                        (Fractal objects, PNG support)
  20613.                                CIS: 71320,675
  20614.                         Internet: twegner@phoenix.net
  20615.  
  20616.                                  Drew Wells
  20617.             (POV-Ray 1.0 developer, POV-Ray 1.0 team coordinator)
  20618.  
  20619.                                  Chris Young
  20620.       (POV-Ray 1.0/2.0/3.0 developer, POV-Ray 2.0/3.0 team coordinator)
  20621.                                CIS: 76702,1655
  20622.  
  20623.  
  20624. APPENDIX C       Contacting the Authors
  20625.  
  20626. The POV-Team is a collection of volunteer programmers, designers, animators
  20627. and artists meeting via electronic mail on Compuserve's POVRAY forum (GO
  20628. POVRAY).
  20629.  
  20630. The POV-Team's goal is to create freely distributable, high quality rendering
  20631. and animation software written in C that can be easily ported to many
  20632. different computers.
  20633.  
  20634. If you have any questions about POV-Ray, please contact   Chris Young
  20635.   POV-Team Coordinator
  20636.   CIS: 76702,1655
  20637.   Internet: 76702.1655@compuserve.com
  20638.  
  20639.  
  20640. We love to hear about how you're using and enjoying the program. We also will
  20641. do our best try to solve any problems you have with POV-Ray and incorporate
  20642. good suggestions into the program.
  20643.  
  20644. If you have a question regarding commercial use of, distribution of, or
  20645. anything particularly sticky, please contact Chris Young, the development
  20646. team coordinator. Otherwise, spread the mail around. We all love to hear from
  20647. you!
  20648.  
  20649. The best method of contact is e-mail through CompuServe for most of us.
  20650. America On-Line and Internet can now send mail to CompuServe, also, just use
  20651. the Internet address and the mail will be sent through to CompuServe where we
  20652. read our mail daily.
  20653.  
  20654. Please do not send large files to us through the e-mail without asking first.
  20655. We pay for each minute on CompuServe and large files can get expensive. Send
  20656. a query before you send the file, thanks!
  20657.  
  20658. APPENDIX D       Postcards for POV-Ray Team Members
  20659.  
  20660. If you want to personally thank some of the POV-Ray Team members you can send
  20661. them a postcard from wherever you are. To avoid invalid addresses from
  20662. floating around (in case some of us move) the addresses listed below (in
  20663. alphabetical order) are only valid until the given date.
  20664.  
  20665.   Dieter Bayer
  20666.   Taeublingstr. 26
  20667.   91058 Erlangen
  20668.   Germany                                    (until 31. July 1997)
  20669.  
  20670.   Chris Cason                                (Windows version)
  20671.   PO Box 407
  20672.   Williamstown
  20673.   Victoria 3016
  20674.   Australia                                  (until 31. December 1998)
  20675.  
  20676.   Joel NewKirk
  20677.   255-9 Echelon Rd
  20678.   Voorhees, NJ, USA, 08043                   (until ---)
  20679.  
  20680.   Eduard Schwan                              (Macintosh version)
  20681.   1112 Oceanic Drive
  20682.   Encinitas, California, USA, 92024-4007     (until 30. June 1998)
  20683.  
  20684.  
  20685. You should also be aware that we do not answer any questions asked by regular
  20686. mail or phone, we only reply to e-mails. Send any questions you have to the
  20687. e-mail address mentioned in section "Contacting the Authors".
  20688.  
  20689. APPENDIX E       Credits
  20690.  
  20691. Credits for providing contributions to the user documentation go to (in
  20692. alphabetical order):
  20693.  
  20694.                                Charles Fusner
  20695.                       (Blob, lathe and prism tutorial)
  20696.  
  20697.  
  20698. APPENDIX F       Tips and Hints
  20699.  
  20700.  
  20701. APPENDIX F.1     Scene Design Tips
  20702.  
  20703. There are a number of excellent shareware CAD style modelers available on the
  20704. DOS platform now that will create POV-Ray scene files. The online systems
  20705. mentioned elsewhere in this document are the best places to find these.
  20706.  
  20707. Hundreds of special-purpose utilities have been written for POV-Ray: data
  20708. conversion programs, object generators, shell-style launchers and more. It
  20709. would not be possible to list them all here, but again, the online systems
  20710. listed will carry most of them. Most, following the POV-Ray spirit, are
  20711. freeware or inexpensive shareware.
  20712.  
  20713. Some extremely elaborate scenes have been designed by drafting on graph
  20714. paper. Raytracer Mike Miller recommends graph paper with a grid divided in
  20715. tenths, allowing natural decimal conversions.
  20716.  
  20717. Start out with a boilerplate scene file, such as a copy of basicvue.pov, and
  20718. edit that. In general, place your objects near and around the origin with the
  20719. camera in the negative z-direction, looking at the origin. Naturally, you
  20720. will break from this rule many times, but when starting out, keep things
  20721. simple.
  20722.  
  20723. For basic, boring, but dependable lighting, place a light source at or near
  20724. the position of the camera. Objects will look flat, but at least you will see
  20725. them. From there, you can move it slowly into a better position.
  20726.  
  20727. APPENDIX F.2     Scene Debugging Tips
  20728.  
  20729. To see a quick version of your picture, render it very small. With fewer
  20730. pixels to calculate the ray-tracer can finish more quickly. -W160 -H100 is a
  20731. good size.
  20732.  
  20733. Use the +Q quality switch when appropriate.
  20734.  
  20735. If there is a particular area of your picture that you need to see in high
  20736. resolution, perhaps with anti-aliasing on (perhaps a fine-grained wood
  20737. texture), use the +SC, +EC, +SR and +ER switches to isolate a window.
  20738.  
  20739. If your image contains a lot of inter-reflections, set max_trace_level to a
  20740. low value such as 1 or 2. Don't forget to put it back up when you're
  20741. finished!
  20742.  
  20743. Turn off any unnecessary lights. Comment out extended light keywords when not
  20744. needed for debugging. Again, don't forget to put them back in before you
  20745. retire for the night with a final render running!
  20746.  
  20747. If you've run into an error that is eluding you by visual examination it's
  20748. time to start bracketing your file. Use the block comment characters /* ...
  20749. */ to disable most of your scene and try to render again. If you no longer
  20750. get an error the problem naturally lies somewhere within the disabled area.
  20751. Slow and methodical testing like this will eventually get you to a point
  20752. where you will either be able to spot the bug, or go quietly insane. Maybe
  20753. both.
  20754.  
  20755. If you seem to have lost yourself or an object (a common experience for
  20756. beginners) there are a few tricks that can sometimes help:
  20757.  
  20758.   1)Move your camera way back to provide a long range view. This may not help
  20759.     with very small objects which tend to be less visible at a distance, but
  20760.   2)Try setting the ambient value to 1.0 if you suspect that the object may
  20761.     simply be hidden from the lights. This will make it self-illuminated and
  20762.   3)Replace the object with a larger, more obvious "stand-in" object like a
  20763.     large sphere or box. Be sure that all the same transformations are
  20764.     applied to this new shape so that it ends up in the same spot.
  20765.  
  20766. APPENDIX F.3     Animation Tips
  20767.  
  20768. When animating objects with solid textures, the textures must move with the
  20769. object, i. e. apply the same rotate or translate functions to the texture as
  20770. to the object itself. This is now done automatically if the transformations
  20771. are placed after the texture block like the following example
  20772.  
  20773.   shape { ...
  20774.     pigment { ... }
  20775.     scale < ... >
  20776.   }
  20777.  
  20778.  
  20779. will scale the shape and pigment texture by the same amount.
  20780.  
  20781.   shape { ...
  20782.     scale < ... >
  20783.     pigment { ... }
  20784.   }
  20785.  
  20786.  
  20787. will scale the shape but not the pigment.
  20788.  
  20789. Constants can be declared for most of the data types in the program including
  20790. floats and vectors. By writing these to include files you can easily separate
  20791. the parameters for an animation into a separate file.
  20792.  
  20793. Some examples of declared constants would be:
  20794.  
  20795.    #declare Y_Rotation = 5.0 * clock
  20796.    #declare ObjectRotation = <0, Y_Rotation, 0>
  20797.    #declare MySphere = sphere { <0, 0, 0>, 1.1234 }
  20798.  
  20799.  
  20800. Other examples can be found scattered throughout the sample scene files.
  20801.  
  20802. A tip for MS-Dos users: Get ahold of dta.exe (Dave's Targa Animator) for
  20803. creating .FLI/.FLC animations. aaplay.exe and play.exe are common viewers for
  20804. this type of file.
  20805.  
  20806. When moving the camera in an animation (or placing one in a still image, for
  20807. that matter) avoid placing the camera directly over the origin. This will
  20808. cause very strange errors. Instead, move off center slightly and avoid
  20809. hovering directly over the scene.
  20810.  
  20811. APPENDIX F.4     Texture Tips
  20812.  
  20813. Wood is designed like a log with growth rings aligned along the z-axis.
  20814. Generally these will look best when scaled down by about a tenth (to a
  20815. unit-sized object). Start out with rather small value for the turbulence too
  20816. (around 0.05 is good for starters).
  20817.  
  20818. The marble texture is designed around a pigment primitive that is much like
  20819. an x-gradient. When turbulated, the effect is different when viewed from the
  20820. side or from the end. Try rotating it by 90 degrees on the y-axis to see the
  20821. difference.
  20822.  
  20823. You cannot get specular highlights on a totally black object. Try using a
  20824. very dark gray, say Gray10 or Gray15 (from colors.in), instead.
  20825.  
  20826. APPENDIX F.5     Height Field Tips
  20827.  
  20828. Try using POV-Ray itself to create images for height fields:   camera { locat
  20829.   plane { z, 0
  20830.      finish { ambient 1 }    // needs no light sources
  20831.      pigment { bozo }        // or whatever.  Experiment.
  20832.   }
  20833.  
  20834.  
  20835. That's all you'll need to create a .tga file that can then be used as a
  20836. height field in another image!
  20837.  
  20838. APPENDIX F.6     Converting "Handedness"
  20839.  
  20840. If you are importing images from other systems you may find that the shapes
  20841. are backwards (left-to-right inverted) and no rotation can make them correct.
  20842.  
  20843.  
  20844. Often, all you have to do is negate the terms in the right vector of the
  20845. camera to flip the camera left-to-right (use the right-hand coordinate
  20846. system). Some programs seem to interpret the coordinate systems differently,
  20847. however, so you may need to experiment with other camera transformations if
  20848. you want the y- and z-vectors to work as POV-Ray does.
  20849.  
  20850. APPENDIX G       Frequently Asked Questions
  20851.  
  20852. This is a collection of frequently asked questions and their answers taken
  20853. directly from messages posted in the POVRAY Forum on Compuserve and the
  20854. comp.graphics.raytracing newsgroup.
  20855.  
  20856. This version of the FAQ is heavily biased towards the CompuServe user of the
  20857. IBM PC version of POV-Ray. Hopefully later revisions will remove some of this
  20858. bias, but at present time, that is the largest audience.
  20859.  
  20860. APPENDIX G.1     General Questions
  20861.  
  20862.  
  20863. APPENDIX G.2     POV-Ray Options Questions
  20864.  
  20865. Q: How can I set mosaic preview to go from 8*straight to final render without
  20866. going to 4*and then 2*first? A: Use the +SPn or Preview_Start_Size option to
  20867. set the starting resolution and the +EPn or Preview_End_Size option to set
  20868. the ending resolution. With +SP8 and +EP8 it will go from 8*8 down to 8*8
  20869. (just one pass) then immediately drop into the final pass at 1*1.
  20870.  
  20871. Q: Should the +MB switch be used in very small scenes, i. e. with a low
  20872. number of objects. A: That depends on the number of objects and their type.
  20873. Normally it doesn't hurt to always use the bounding box hierarchy (+MB0). If
  20874. you have just one or two objects it may be better to not use automatic
  20875. bounding.
  20876.  
  20877. Q: Does the +MB switch affect the quality of the image? A: No. It only
  20878. affects the speed of the intersection tests.
  20879.  
  20880. Q: How do I avoid that the options screen scrolls off when error messages are
  20881. generated? A: Use the +P switch. Everytime POV-Ray is interrupted or the
  20882. tracing finishes you can use the cursor keys to scroll-back the options text.
  20883.  
  20884. APPENDIX G.3     Include File Questions
  20885.  
  20886. Q: In the file textures.v2, the glass textures are commented out. Why? A: The
  20887. old glass textures are duplicated in glass.inc. The old texture names didn't
  20888. fit in with the new naming scheme. Glass is now T_Glass1, Glass2 is now
  20889. T_Glass2 and Glass3 is now T_Glass3. While you can easily un-comment the old
  20890. names you're strongly encouraged to use the newer naming scheme.
  20891.  
  20892. APPENDIX G.4     Object Questions
  20893.  
  20894.  
  20895. APPENDIX G.4.1   Height Field Questions
  20896.  
  20897. Q: I have a lowly 8 meg of RAM on my computer and I ran out of memory trying
  20898. to use a 1024x768 pot file and a gif of the same resolution as height fields
  20899. (two different scenes). Is it my memory thats low or is that resolution
  20900. crazy? A: Smoothed heightfields will consume a lot more memory (about three
  20901. times as much) as one that isn't smoothed. Since smoothing really isn't
  20902. neccessary at those resolutions don't smooth (if you're smoothing).
  20903.  
  20904. Q: I want to use the same image for an image map and a height-field (which
  20905. gives some meaningful relationship between the height and colors). Does that
  20906. only work when using a gif or bmp format? I couldn't get the pot file to map
  20907. (format not supported). A: pot files are not supported as image maps. Their
  20908. purpose to POV-Ray is as heightfields. That doesn't prevent you from making a
  20909. matching gif in fractint that uses the continuous potential coloring that you
  20910. used for the 16 bit pot file, and using that as the image map. Remember that
  20911. both image maps and height fields are initialized in a 1*1(*1) area, with the
  20912. lower-left of the image situated at the origin. The image map is initiated in
  20913. the x-y-plane while the height field is in the x-z plane. Thus you'll have to
  20914. rotate the image map by 90 degrees around the x-axis (use rotate x*90) to get
  20915. the image map to line up.
  20916.  
  20917. APPENDIX G.4.2   Text Questions
  20918.  
  20919. Q: Is there any possibility to know the size of a font-object? A: Sadly no.
  20920. We really need it but its not easy to do. Until just days before beta release
  20921. the horizontal spacing didn't even work right. Now that we've got that fixed,
  20922. perhaps we can figure a way to get the length.
  20923.  
  20924. APPENDIX G.5     Atmospheric Questions
  20925.  
  20926.  
  20927. APPENDIX G.5.1   Atmosphere Questions
  20928.  
  20929. Q: Why is the atmosphere I added not visible? A: The most common error made
  20930. when adding an atmosphere to a scene is the missing hollow keyword in all
  20931. objects the camera currently is in. If you are inside a box that is used to
  20932. model a room you'll have to add the hollow keyword to the box statement. If a
  20933. plane is used to model the ground you'll have to make it hollow (only if you
  20934. are inside the plane, but to be sure you can always do it).
  20935.  
  20936. If this doesn't help there may be other problems you'll have to verify. The
  20937. distance and scattering values of the atmosphere have to be larger than zero.
  20938. Light sources that shall interact with the atmosphere mustn't contain an
  20939. atmosphere off statement.
  20940.  
  20941. Q: Why can't I see any atmosphere through my translucent object? A: If you
  20942. have a translucent object you (almost) always have to make it hollow by
  20943. adding the hollow keyword. Whenever an intersection is found and the ray is
  20944. inside a solid object no atmospheric effects will be calculated.
  20945.  
  20946. If you have a partially transparent plane for example the atmosphere on the
  20947. other side of the plane will only be visible through the plane if this plane
  20948. is hollow.
  20949.  
  20950. Q: Why do the lit parts of the atmosphere amplify the background? A: First,
  20951. they don't.
  20952.  
  20953. Second, whenever parts of the background are visible through the atmosphere
  20954. and those areas of the atmosphere are lit by any light source, the scattered
  20955. light is added to the light coming from the background. This is the reason
  20956. why the background seems to be amplified by the atmosphere. Just imagine the
  20957. followoing example: you have a blue background that is attenuated be the
  20958. atmosphere in a way that the color reaching the viewer is <0,0,0.2>. Now some
  20959. light coming from a light source is attenuated and scattered by the
  20960. atmosphere and finally reaches the viewer with a color of <0.5,0.5,0.5>.
  20961. Since we already have light coming from the background, both colors are added
  20962. to give <0.5,0.5,0.7>. Thus the light gets a blue hue. As a result you think
  20963. that the background light is amplified but it isn't as the following scene
  20964. clearly shows.
  20965.  
  20966. #version 3.0
  20967.   camera {
  20968.     location <0, 6, -20>
  20969.     look_at <0, 6, 0>
  20970.     angle 48
  20971.   }
  20972.  
  20973.   atmosphere {
  20974.     type 1
  20975.     samples 10
  20976.     distance 20
  20977.     scattering 0.3
  20978.     aa_level 3
  20979.     aa_threshold 0.1
  20980.     jitter 0.2
  20981.   }
  20982.  
  20983.   light_source { <0, 15, 0> color rgb .7 shadowless }
  20984.  
  20985.   light_source {
  20986.     <-5, 15, 0> color rgb <1, 0, 0>
  20987.     spotlight
  20988.     point_at <-5, 0, 0>
  20989.     radius 10
  20990.     falloff 15
  20991.     tightness 1
  20992.     atmospheric_attenuation on
  20993.   }
  20994.  
  20995.   light_source {
  20996.     <0, 15, 0> color rgb <0, 1, 0>
  20997.     spotlight
  20998.     point_at <0, 0, 0>
  20999.     radius 10
  21000.     falloff 15
  21001.     tightness 1
  21002.     atmospheric_attenuation on
  21003.   }
  21004.  
  21005.   light_source {
  21006.     <5, 15, 0> color rgb <0, 0, 1>
  21007.     spotlight
  21008.     point_at <5, 0, 0>
  21009.     radius 10
  21010.     falloff 15
  21011.     tightness 1
  21012.     atmospheric_attenuation on
  21013.   }
  21014.  
  21015.   plane { z, 10
  21016.     pigment { checker color rgb<1, 0, 0> color rgb<0, 1, 0> }
  21017.     hollow
  21018.   }
  21019.  
  21020.  
  21021. The atmosphere seems to amplify what is seen in the background.
  21022.  
  21023. In the background you see a red/green checkered plane. The background color
  21024. visible through the atmosphere is added to the light scattered from the
  21025. spotlights. You'll notice that even though the red squares behind the red
  21026. spotlight's cone are brighter than those outside the cone the green ones are
  21027. not. For the green spotlight the situation is turned around: the green
  21028. squares seem to be amplified while the red are not. The blue spotlight
  21029. doesn't show this effect at all.
  21030.  
  21031. Q: The docs say the distance parameter for atmosphere works in the same way
  21032. as fog distance. Is that right? A: Yes, that's right. Try to use a fog
  21033. instead of the atmosphere. If everything looks good, i. e. you still can see
  21034. the background or whatever you want to see, use the same distance and color
  21035. for the atmosphere.
  21036.  
  21037. APPENDIX G.5.2   Fog Questions
  21038.  
  21039. Q: I'm using moray to build a scene containing a ground fog. The problem is
  21040. that the fog fades out along the y-axis. In moray the z-axis is up, so I have
  21041. a wall of fog, rather than a layer. What to do? A: There is an up keyword
  21042. that can be used to specify the up direction the ground fog is using. Adding
  21043. the line up z to your fog will help.
  21044.  
  21045. APPENDIX H       Suggested Reading
  21046.  
  21047. Beside the POV-Ray specific books mentioned in "POV-Ray Related Books and
  21048. CD-ROMs" there are several good books or periodicals that you should be able
  21049. to locate in your local computer book store or your local university library.
  21050.  
  21051.  
  21052.   "An Introduction to Ray tracing"
  21053.   Andrew S. Glassner (editor)
  21054.   ISBN 0-12-286160-4
  21055.   Academic Press
  21056.   1989
  21057.  
  21058.   "3D Artist" Newsletter
  21059.   "The Only Newsletter about Affordable
  21060.    PC 3D Tools and Techniques")
  21061.   Publisher: Bill Allen
  21062.   P.O. Box 4787
  21063.   Santa Fe, NM 87502-4787
  21064.   (505) 982-3532
  21065.  
  21066.   "Image Synthesis:  Theory and Practice"
  21067.   Nadia Magnenat-Thalman and Daniel Thalmann
  21068.   Springer-Verlag
  21069.   1987
  21070.  
  21071.   "The RenderMan Companion"
  21072.   Steve Upstill
  21073.   Addison Wesley
  21074.   1989
  21075.  
  21076.   "Graphics Gems"
  21077.   Andrew S. Glassner (editor)
  21078.   Academic Press
  21079.   1990
  21080.  
  21081.   "Fundamentals of Interactive Computer Graphics"
  21082.   J. D. Foley and A. Van Dam
  21083.   ISBN 0-201-14468-9
  21084.   Addison-Wesley
  21085.   1983
  21086.  
  21087.   "Computer Graphics:  Principles and Practice (2nd Ed.)"
  21088.   J. D. Foley, A. van Dam, J. F. Hughes
  21089.   ISBN 0-201-12110-7
  21090.   Addison-Wesley,
  21091.   1990
  21092.  
  21093.   "Computers, Pattern, Chaos, and Beauty"
  21094.   Clifford Pickover
  21095.   St. Martin's Press
  21096.  
  21097.   "SIGGRAPH Conference Proceedings"
  21098.   Association for Computing Machinery
  21099.   Special Interest Group on Computer Graphics
  21100.  
  21101.   "IEEE Computer Graphics and Applications"
  21102.   The Computer Society
  21103.   10662, Los Vaqueros Circle
  21104.   Los Alamitos, CA 90720
  21105.  
  21106.   "The CRC Handbook of Mathematical Curves and Surfaces"
  21107.   David von Seggern
  21108.   CRC Press
  21109.   1990
  21110.  
  21111.   "The CRC Handbook of Standard Mathematical Tables"
  21112.   CRC Press
  21113.   The Beginning of Time
  21114.  
  21115.  
  21116. APPENDIX I       Help on Help
  21117.  
  21118. Using the Help Reader (POVHELP.EXE)
  21119.  
  21120. KNOWN INCOMPATIBILITIES
  21121.  
  21122. See after the Quick Intro.
  21123.  
  21124. Quick Intro
  21125.  
  21126. Use the +E option to make the help reader a pop-up program. Use Space to go
  21127. to the next section. Use Ctrl-PgUp and Ctrl-PgDn to move between sections
  21128. also. Use Tab to highlight hypertext links. Use Alt-Tab to highlight code
  21129. fragments. Use Enter to jump to a highlighted hypertext link. Use +/- to jump
  21130. to relevant sections once link jumping has started. Use BACKSPACE to return
  21131. to the last place you were before a search/jump. Use 'S' to search on a
  21132. keyword. Use 'J' to toggle text justification when reading a section. Use 'P'
  21133. to paste code into your application via the keyboard buffer.
  21134.  
  21135. POV-Help will handle non-standard page widths provided the BIOS column count
  21136. is correctly updated by whatever program is being used to alter it from 80
  21137. columns.
  21138.  
  21139. If you use POV-Help as a pop-up program, it will attempt to search on the
  21140. word under your cursor when you pop it up. Note that if you exit pop-up mode
  21141. by using the hot-key (the default is ALT-ESC), POV-Help takes this to mean
  21142. that you want to return to the same place next time and will not perform a
  21143. search. A search is only performed if you exited using ESCAPE (meaning you
  21144. have finished with the current subject.)
  21145.  
  21146. The history stack activated by using Backspace holds 32 entries.
  21147.  
  21148. KNOWN INCOMPATIBILITIES
  21149.  
  21150. POV-Help does not work with MS-DOS's EDIT program. [In fact, EDIT.COM is
  21151. really QBASIC.EXE with a few add ons ; EDIT needs QBASIC to run.]
  21152.  
  21153. If it won't work with your editor, try this (assuming you have macro
  21154. facilities) -
  21155.  
  21156.   o bind the macro to your key-sequence of choice.rameter
  21157.  
  21158.  
  21159. Command Line (case insensitive)
  21160.  
  21161.   +Tsphere or "+Tsphere"go straight to the first section found with  'sphere'
  21162.   +PH[n]                send 'n' HOME keys after each CR when pasting.
  21163.   +KALT-ESC             hot key sequence. can be CTRL|ALT|CTRL-ALT+[Any
  21164.                         character]|[ESC]. e.g. +KCTRL-ALT-P, +KCTRL-1,
  21165.   +Eabc d e             run program 'abc' with parameters 'd' and 'e'. all
  21166.   text                  same as +T unless collecting +E parameters, where it
  21167.                         is a parameter
  21168.  
  21169.  
  21170. Viewer Commands
  21171.  
  21172. Top Menu
  21173.  
  21174.   Escapewnexit help viewerem
  21175.  
  21176.  
  21177. Authors, Copyright
  21178.  
  21179.   EscapeRightreturn to top menu
  21180.  
  21181.  
  21182. Section
  21183.  
  21184.   "P"TababertrlPgDnpaste highlighted code fragment via keyboard buffer.ing)
  21185.  
  21186.  
  21187. General
  21188.  
  21189. The help reader wraps most text. Excluded are specified portions, lists, and
  21190. a few others. Use the left and right arrow keys to scroll these if need be.
  21191.  
  21192. The help reader is intended to be a 'shell' around an editor program. Some
  21193. people may prefer the term 'shim'.
  21194.  
  21195. Using EMS for most memory requirements, it loads itself and then runs your
  21196. editor for you, providing pop-up help facilities. It will also be able to
  21197. paste code fragments into your source. If your editor was, for example, 'ME',
  21198. you would place a batch file called 'ME.BAT' in your scene development
  21199. directory. If you use 'VI', you'd create 'VI.BAT', and so on.
  21200.  
  21201. (YOUR-EDITOR-NAME.BAT)
  21202.  
  21203. desired key sequence ----
  21204.                         |
  21205.         ----------- -------------- ----------------
  21206. povhelp |+W50 +H15≥ |+KCTRL-ALT-H| |+Ed:\me\me.exe| %1 %2 %3 %4 %5
  21207.         ----------- -------------- ----------------
  21208.                 |                      |
  21209. size of window --                      |
  21210.                                        |
  21211. place path to your editor here ---------
  21212.  
  21213.  
  21214. For example -
  21215.  
  21216. povhelp +W50 +H15 +KALT-H +Ed:\me\me.exe %1 %2 %3 %4 %5
  21217.  
  21218.  
  21219. This command line will yield a version of POV-Help with a 50x15 window,
  21220. popped-up with the ALT-H key sequence, over the editor 'd:\me\me.exe'. If you
  21221. don't specify a key sequence, POV-Help defaults to using ALT-ESC.
  21222.  
  21223. This would load the help reader. which would then load ME.EXE, and things
  21224. would proceed as normal. When you exit your editor, the help reader
  21225. automatically unloads. You can use the ALT-ESC key sequence to pop up
  21226. POVHELP. This is the default ; there is a way to set it. Note that no other
  21227. parameters may appear after the +E parameter as they will just be passed to
  21228. the program being run.
  21229.  
  21230. If you use the hotkey to pop-up, POVHELP performs a simplistic search of
  21231. sections and titles based on the word under the cursor. If found, you are
  21232. taken to that. Otherwise, you are taken to the main menu, unless you
  21233. hot-keyed out.
  21234.  
  21235. You can hot-key out of the actual section text, by using the same hot key
  21236. that got you in. If you press escape, you are taken back up to the top menu.
  21237. But if you hotkey out, you go back to your program. Next time you press the
  21238. hot key, you will be taken back to the same place. No search is performed in
  21239. this case.
  21240.  
  21241. POVHELP needs EMS if it is running as a shell program.
  21242.  
  21243. If
  21244. you don't specify the +E parameter, POVHELP will come up as a stand-alone
  21245. program, in which case it does not use EMS.
  21246.  
  21247. If you highlight a section of code using Alt-Tab, and you are using POV-Help
  21248. in pop-up mode, then you may paste the code via the keyboard buffer using
  21249. 'P'.
  21250.  
  21251. As many editors today use auto-indentation, this may cause some problems with
  21252. column alignment. For that reason, POV-Help by default inserts a HOME key
  21253. code into the keyboard buffer after each CR. Some editors require more than
  21254. one HOME key operation to get to the left column. For this reason, the number
  21255. of HOME's sent may be adjusted from 0 (none) to 9 using the +PH[n]
  21256. command-line parameter. 'n' is any value from 0 to 9 and defaults to 1.
  21257.  
  21258. POV-Help was written by  Christopher J. Cason.
  21259. CIS      : 100032,1644.
  21260. Internet : cjcason@yarrow.wt.uwa.edu.au.
  21261.  
  21262. Converters will be available which translate POV-Help databases to other
  21263. formats such as Postscript, LaTeX, RTF, Windows Help, HTML, etc.
  21264.  
  21265. The format of the POV-Help database is documented and freely available.
  21266.  
  21267. POV-Help is free. It may not be sold. See POVLEGAL.DOC for details. The
  21268. POV-Help suite of programs is copyright  (c) 1994 C.J. Cason and the
  21269. POV-Team.
  21270.  
  21271.  
  21272.